UnityEditor.EditorGUIExt.ScrollerRepeatButton C# (CSharp) Method

ScrollerRepeatButton() private static method

private static ScrollerRepeatButton ( int scrollerID, Rect rect, GUIStyle style ) : bool
scrollerID int
rect UnityEngine.Rect
style UnityEngine.GUIStyle
return bool
        private static bool ScrollerRepeatButton(int scrollerID, Rect rect, GUIStyle style)
        {
            bool flag = false;
            if (DoRepeatButton(rect, GUIContent.none, style, FocusType.Passive))
            {
                bool flag2 = scrollControlID != scrollerID;
                scrollControlID = scrollerID;
                if (flag2)
                {
                    flag = true;
                    nextScrollStepTime = Time.realtimeSinceStartup + (0.001f * firstScrollWait);
                }
                else if (Time.realtimeSinceStartup >= nextScrollStepTime)
                {
                    flag = true;
                    nextScrollStepTime = Time.realtimeSinceStartup + (0.001f * scrollWait);
                }
                if (Event.current.type == EventType.Repaint)
                {
                    HandleUtility.Repaint();
                }
            }
            return flag;
        }

Usage Example

示例#1
0
        public static void MinMaxScroller(Rect position, int id, ref float value, ref float size, float visualStart, float visualEnd, float startLimit, float endLimit, GUIStyle slider, GUIStyle thumb, GUIStyle leftButton, GUIStyle rightButton, bool horiz)
        {
            float num;

            if (horiz)
            {
                num = size * 10f / position.width;
            }
            else
            {
                num = size * 10f / position.height;
            }
            Rect position2;
            Rect rect;
            Rect rect2;

            if (horiz)
            {
                position2 = new Rect(position.x + leftButton.fixedWidth, position.y, position.width - leftButton.fixedWidth - rightButton.fixedWidth, position.height);
                rect      = new Rect(position.x, position.y, leftButton.fixedWidth, position.height);
                rect2     = new Rect(position.xMax - rightButton.fixedWidth, position.y, rightButton.fixedWidth, position.height);
            }
            else
            {
                position2 = new Rect(position.x, position.y + leftButton.fixedHeight, position.width, position.height - leftButton.fixedHeight - rightButton.fixedHeight);
                rect      = new Rect(position.x, position.y, position.width, leftButton.fixedHeight);
                rect2     = new Rect(position.x, position.yMax - rightButton.fixedHeight, position.width, rightButton.fixedHeight);
            }
            float num2 = Mathf.Min(visualStart, value);
            float num3 = Mathf.Max(visualEnd, value + size);

            EditorGUIExt.MinMaxSlider(position2, ref value, ref size, num2, num3, num2, num3, slider, thumb, horiz);
            bool flag = false;

            if (Event.current.type == EventType.MouseUp)
            {
                flag = true;
            }
            if (EditorGUIExt.ScrollerRepeatButton(id, rect, leftButton))
            {
                value -= num * ((visualStart >= visualEnd) ? -1f : 1f);
            }
            if (EditorGUIExt.ScrollerRepeatButton(id, rect2, rightButton))
            {
                value += num * ((visualStart >= visualEnd) ? -1f : 1f);
            }
            if (flag && Event.current.type == EventType.Used)
            {
                EditorGUIExt.scrollControlID = 0;
            }
            if (startLimit < endLimit)
            {
                value = Mathf.Clamp(value, startLimit, endLimit - size);
            }
            else
            {
                value = Mathf.Clamp(value, endLimit, startLimit - size);
            }
        }