Ejemplo n.º 1
0
        public void Dispose()
        {
            GUIContentPool.Dispose(ref label);
            onClicked = null;
            hasColor  = false;

            var disposing = this;

            pool.Dispose(ref disposing);
        }
Ejemplo n.º 2
0
        public static void DisposeContent(ref GUIContent[] disposing)
        {
            int length = disposing.Length;

            for (int n = length - 1; n >= 0; n--)
            {
                var member = disposing[n];
                if (member != null)
                {
                    GUIContentPool.Dispose(ref member);
                }
            }
        }
Ejemplo n.º 3
0
        /// <inheritdoc />
        public sealed override void OnMouseover()
        {
            if (mouseoveredSubPart == SliderSubPart.Slider)
            {
                OnMouseoverSlider();
            }
            else if (mouseoveredSubPart == SliderSubPart.NumberField)
            {
                if (HasNumberField)
                {
                    DrawGUI.DrawMouseoverEffect(NumberFieldPosition, localDrawAreaOffset);
                }

                var valueString = StringUtils.ToString(Value);
                if (valueString.Length > 6)
                {
                    var tooltip     = GUIContentPool.Create(valueString);
                    var tooltipRect = labelLastDrawPosition;
                    tooltipRect.y      += 1f;
                    tooltipRect.height -= 2f;

                    var tooltipWidth = DrawGUI.prefixLabel.CalcSize(tooltip).x + 3f;
                    tooltipRect.x     = controlLastDrawPosition.x - tooltipWidth - DrawGUI.MiddlePadding - DrawGUI.MiddlePadding;
                    tooltipRect.width = tooltipWidth;

                    DrawGUI.Active.TooltipBox(tooltipRect, tooltip);
                    GUIContentPool.Dispose(ref tooltip);
                }
            }
            else if (MouseOverPart == PrefixedControlPart.Prefix)
            {
                if (InspectorUtility.Preferences.mouseoverEffects.prefixLabel)
                {
                    DrawGUI.DrawLeftClickAreaMouseoverEffect(PrefixLabelPosition, localDrawAreaOffset);
                }

                if (!ReadOnly)
                {
                    DrawGUI.Active.SetCursor(MouseCursor.SlideArrow);

                    if (HasNumberField)
                    {
                        //UPDATE: highlight the control even when mouseovering the prefix
                        //to make it clear than dragging will change the value of that field
                        DrawGUI.DrawMouseoverEffect(NumberFieldPosition, localDrawAreaOffset);
                    }
                }
            }
        }
Ejemplo n.º 4
0
            public void Dispose()
            {
                if (label == GUIContent.none)
                {
                    label = null;
                }
                else
                {
                    GUIContentPool.Dispose(ref label);
                }

                methodOwner          = null;
                on                   = false;
                effect               = null;
                effectWithParameter  = null;
                effectParameterValue = null;
                isSeparator          = false;
            }
Ejemplo n.º 5
0
        public static void RemoveAt(ref GUIContent[] target, int index)
        {
            int oldSize = target.Length;
            int newSize = oldSize - 1;
            var result  = Create(newSize);

            for (int n = oldSize - 1; n > index; n--)
            {
                result[n - 1] = target[n];
                target[n]     = null;
            }

            GUIContentPool.Dispose(ref target[index]);

            for (int n = index - 1; n >= 0; n--)
            {
                result[n] = target[n];
                target[n] = null;
            }

            Dispose(ref target, false);

            target = result;
        }
Ejemplo n.º 6
0
        private void OnMouseoverSlider()
        {
            //trigger a repaint every frame for better responsiveness
            GUI.changed = true;

            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            var currentDrawAreaOffset    = DrawGUI.GetLocalDrawAreaOffset();
            var drawAreaOffsetDifference = currentDrawAreaOffset - localDrawAreaOffset;

            var visualSliderRect = SliderPosition;

            var effectiveSliderRect = SliderClickableAreaRect;

            var mousePos = Event.current.mousePosition;

            var effectiveMouseX = Mathf.Clamp(mousePos.x + drawAreaOffsetDifference.x, effectiveSliderRect.x + drawAreaOffsetDifference.x, effectiveSliderRect.x + drawAreaOffsetDifference.x + effectiveSliderRect.width);
            var valueAtCursor   = GetSliderValueAt(effectiveMouseX);

            double pCurrent      = MathUtils.Subtract(Value, min) / MathUtils.Subtract(max, min);
            int    currentValueX = (int)(visualSliderRect.x + MathUtils.Lerp(0d, visualSliderRect.width, pCurrent));

            //if cursor is not over the slider then draw the click cursor
            //and display value at current cursor position as a tooltip
            int diff = MathUtils.Abs(Mathf.RoundToInt(effectiveMouseX - currentValueX));

            if (diff > 6)
            {
                var tooltip = GUIContentPool.Create(StringUtils.ToString(valueAtCursor));

                var tooltipRect = labelLastDrawPosition;
                tooltipRect.x      -= drawAreaOffsetDifference.x;
                tooltipRect.y      -= drawAreaOffsetDifference.y;
                tooltipRect.height -= 2f;
                var tooltipWidth = DrawGUI.tooltipStyle.CalcSize(tooltip).x;
                tooltipRect.x     = mousePos.x - tooltipWidth * 0.5f + 1f;
                tooltipRect.y    -= DrawGUI.SingleLineHeight;
                tooltipRect.width = tooltipWidth;

                DrawGUI.Active.TooltipBox(tooltipRect, tooltip);
                GUIContentPool.Dispose(ref tooltip);

                effectiveSliderRect.x     = mousePos.x - 3f;
                effectiveSliderRect.y    -= drawAreaOffsetDifference.y;
                effectiveSliderRect.width = 8f;

                                #if UNITY_2019_3_OR_NEWER
                effectiveSliderRect.y -= 4f;
                                #endif

                var guiColorWas = GUI.color;
                var setGuiColor = guiColorWas;
                setGuiColor.a = 0.5f;
                GUI.color     = setGuiColor;
                GUI.Label(effectiveSliderRect, " ", InspectorPreferences.Styles.RangeIndicator);
                GUI.color = guiColorWas;
            }
        }