コード例 #1
0
        private float OnRepaint()
        {
            bool hover = position.Contains(CurrentEvent().mousePosition);

            slider.Draw(position, GUIContent.none, id, false, hover);
            if (!IsEmptySlider() && currentValue >= Mathf.Min(start, end) && currentValue <= Mathf.Max(start, end))
            {
                if (thumbExtent != null)
                {
                    thumbExtent.Draw(ThumbExtRect(), GUIContent.none, id, false, hover);
                }
                thumb.Draw(ThumbRect(), GUIContent.none, id, false, hover);
            }

            if (GUIUtility.hotControl != id || !hover || IsEmptySlider())
            {
                return(currentValue);
            }

            if (ThumbRect().Contains(CurrentEvent().mousePosition))
            {
                if (GUI.scrollTroughSide != 0) // if was scrolling with "trough" and the thumb reached mouse - sliding action over
                {
                    GUIUtility.hotControl = 0;
                }

                return(currentValue);
            }

            GUI.InternalRepaintEditorWindow();

            if (SystemClock.now < GUI.nextScrollStepTime)
            {
                return(currentValue);
            }

            if (CurrentScrollTroughSide() != GUI.scrollTroughSide)
            {
                return(currentValue);
            }

            GUI.nextScrollStepTime = SystemClock.now.AddMilliseconds(ScrollWaitDefinitions.regularWait);

            if (SupportsPageMovements())
            {
                SliderState().isDragging = false;
                GUI.changed = true;
                return(PageMovementValue());
            }
            return(ClampedCurrentValue());
        }
コード例 #2
0
        private float OnRepaint()
        {
            this.slider.Draw(this.position, GUIContent.none, this.id);
            if (!this.IsEmptySlider())
            {
                this.thumb.Draw(this.ThumbRect(), GUIContent.none, this.id);
            }
            float result;

            if (GUIUtility.hotControl != this.id || !this.position.Contains(this.CurrentEvent().mousePosition) || this.IsEmptySlider())
            {
                result = this.currentValue;
            }
            else if (this.ThumbRect().Contains(this.CurrentEvent().mousePosition))
            {
                if (GUI.scrollTroughSide != 0)
                {
                    GUIUtility.hotControl = 0;
                }
                result = this.currentValue;
            }
            else
            {
                GUI.InternalRepaintEditorWindow();
                if (SystemClock.now < GUI.nextScrollStepTime)
                {
                    result = this.currentValue;
                }
                else if (this.CurrentScrollTroughSide() != GUI.scrollTroughSide)
                {
                    result = this.currentValue;
                }
                else
                {
                    GUI.nextScrollStepTime = SystemClock.now.AddMilliseconds(30.0);
                    if (this.SupportsPageMovements())
                    {
                        this.SliderState().isDragging = false;
                        GUI.changed = true;
                        result      = this.PageMovementValue();
                    }
                    else
                    {
                        result = this.ClampedCurrentValue();
                    }
                }
            }
            return(result);
        }
コード例 #3
0
        private float OnRepaint()
        {
            bool flag = GUIUtility.HitTest(this.position, this.CurrentEvent());

            this.slider.Draw(this.position, GUIContent.none, this.id, false, flag);
            bool flag2 = !this.IsEmptySlider() && this.currentValue >= Mathf.Min(this.start, this.end) && this.currentValue <= Mathf.Max(this.start, this.end);

            if (flag2)
            {
                bool flag3 = this.thumbExtent != null;
                if (flag3)
                {
                    this.thumbExtent.Draw(this.ThumbExtRect(), GUIContent.none, this.id, false, flag);
                }
                this.thumb.Draw(this.ThumbRect(), GUIContent.none, this.id, false, flag);
            }
            bool  flag4 = GUIUtility.hotControl != this.id || !flag || this.IsEmptySlider();
            float result;

            if (flag4)
            {
                result = this.currentValue;
            }
            else
            {
                bool flag5 = GUIUtility.HitTest(this.ThumbRect(), this.CurrentEvent());
                if (flag5)
                {
                    bool flag6 = GUI.scrollTroughSide != 0;
                    if (flag6)
                    {
                        GUIUtility.hotControl = 0;
                    }
                    result = this.currentValue;
                }
                else
                {
                    GUI.InternalRepaintEditorWindow();
                    bool flag7 = SystemClock.now < GUI.nextScrollStepTime;
                    if (flag7)
                    {
                        result = this.currentValue;
                    }
                    else
                    {
                        bool flag8 = this.CurrentScrollTroughSide() != GUI.scrollTroughSide;
                        if (flag8)
                        {
                            result = this.currentValue;
                        }
                        else
                        {
                            GUI.nextScrollStepTime = SystemClock.now.AddMilliseconds(30.0);
                            bool flag9 = this.SupportsPageMovements();
                            if (flag9)
                            {
                                this.SliderState().isDragging = false;
                                GUI.changed = true;
                                result      = this.PageMovementValue();
                            }
                            else
                            {
                                result = this.ClampedCurrentValue();
                            }
                        }
                    }
                }
            }
            return(result);
        }
コード例 #4
0
        private float OnRepaint()
        {
            bool hover = GUIUtility.HitTest(position, CurrentEvent());

            slider.Draw(position, GUIContent.none, id, false, hover);
            if (currentValue >= Mathf.Min(start, end) && currentValue <= Mathf.Max(start, end))
            {
                if (thumbExtent != null)
                {
                    thumbExtent.Draw(ThumbExtRect(), GUIContent.none, id, false, hover);
                }
                thumb.Draw(ThumbRect(), GUIContent.none, id, false, hover);
            }

            if (GUIUtility.hotControl != id || !hover || IsEmptySlider())
            {
                return(currentValue);
            }

            var thumbRect = ThumbRect();

            // If the slider is horizontal then use its entire height to hit test on the thumb
            if (this.horiz)
            {
                thumbRect.y      = position.y;
                thumbRect.height = position.height;
            }
            // ... otherwise use the entire width
            else
            {
                thumbRect.x     = position.x;
                thumbRect.width = position.width;
            }

            if (GUIUtility.HitTest(thumbRect, CurrentEvent()))
            {
                if (GUI.scrollTroughSide != 0) // if was scrolling with "trough" and the thumb reached mouse - sliding action over
                {
                    GUIUtility.hotControl = 0;
                }

                return(currentValue);
            }

            GUI.InternalRepaintEditorWindow();

            if (SystemClock.now < GUI.nextScrollStepTime)
            {
                return(currentValue);
            }

            if (CurrentScrollTroughSide() != GUI.scrollTroughSide)
            {
                return(currentValue);
            }

            GUI.nextScrollStepTime = SystemClock.now.AddMilliseconds(ScrollWaitDefinitions.regularWait);

            if (SupportsPageMovements())
            {
                SliderState().isDragging = false;
                GUI.changed = true;
                return(PageMovementValue());
            }
            return(ClampedCurrentValue());
        }