Example #1
0
        private void Setup(string text, [CanBeNull] LinkedMemberInfo attributeTarget, [CanBeNull] IParentDrawer setParent, HelpBoxMessageType setMessageType = HelpBoxMessageType.Info, IShowInInspectorIf showInInspectorEvaluator = null, float setMinHeight = 31f)
        {
            showHelpBoxEvaluator = showInInspectorEvaluator;
            minHeight            = setMinHeight + PreviousFieldOffset + NextFieldOffset;

            switch (setMessageType)
            {
            case HelpBoxMessageType.Info:
                messageType = MessageType.Info;
                break;

            case HelpBoxMessageType.Warning:
                messageType = MessageType.Warning;
                break;

            case HelpBoxMessageType.Error:
                messageType = MessageType.Error;
                break;

            default:
                throw new IndexOutOfRangeException();
            }

            base.Setup(text, typeof(string), attributeTarget, setParent, GUIContentPool.Create(text), false);

            float drawWidth = setParent != null ? setParent.Bounds.width : DrawGUI.InspectorWidth;

            UpdateHeight(drawWidth - IconWidth);
        }
Example #2
0
        public static Rect GetTextHighlightRectForFilter(string text, Rect position, GUIStyle style, int highlightStart, int highlightCount, float offsetX, float offsetY, float adjustWidth)
        {
                        #if ENABLE_PREFIX_HIGHLIGHTING
            var highlightRect = position;
            highlightRect.x += style.contentOffset.x + style.margin.left - 2f;

            var size = style.CalcSize(GUIContentPool.Temp(text.Substring(0, highlightStart)));
            highlightRect.x += size.x;

            size = style.CalcSize(GUIContentPool.Temp(text.Substring(highlightStart, highlightCount)));
            highlightRect.width = size.x;

            highlightRect.x     += offsetX;
            highlightRect.y     += offsetY;
            highlightRect.width += adjustWidth;

                        #if DEV_MODE && PI_ASSERTATIONS
            Debug.Assert(highlightRect.x >= 0f);
            Debug.Assert(highlightRect.width > 0f);
            Debug.Assert(highlightRect.height > 0f);
                        #endif

            return(highlightRect);
                        #else
            return(null);
                        #endif
        }
Example #3
0
        private void Setup(ParameterInfo[] setParameterInfos, LinkedMemberInfo setMemberInfo, IParentDrawer setParent, GUIContent setLabel, bool setReadOnly)
        {
                        #if DEV_MODE
            if (setReadOnly)
            {
                Debug.LogWarning(StringUtils.ToColorizedString(ToString(), ".Setup - readonly=", true, ". Really don't allow editing parameter value? This is usually desired even for read-only properties."));
            }
                        #endif

            parameterInfos  = setParameterInfos;
            drawInSingleRow = parameterInfos.Length == 1 && DrawerUtility.CanDrawMultipleControlsOfTypeInSingleRow(parameterInfos[0].ParameterType);

            if (setLabel == null)
            {
                setLabel = GUIContentPool.Create("Parameters");
            }

            int count    = parameterInfos.Length;
            var setValue = ArrayPool <object> .Create(count);

            for (int n = count - 1; n >= 0; n--)
            {
                setValue[n] = ParameterValues.GetValue(parameterInfos[n]);
            }

            // always set readonly to false to fix issue where
            // parameters of read-only indexer Properties could not be modified
            base.Setup(setValue, typeof(object[]), setMemberInfo, setParent, setLabel, setReadOnly);
        }
Example #4
0
        private void Setup(Type setGenericTypeDefinition, LinkedMemberInfo setMemberInfo, IParentDrawer setParent, GUIContent setLabel, bool setReadOnly)
        {
                        #if DEV_MODE
            if (setReadOnly)
            {
                Debug.LogWarning(StringUtils.ToColorizedString(ToString(), ".Setup - readonly=", true, ". Really don't allow editing generic type argument? This is usually desired even for read-only properties."));
            }
                        #endif

            genericTypeDefinition = setGenericTypeDefinition;

            var genericTypeArguments = genericTypeDefinition.GetGenericArguments();
            drawInSingleRow = genericTypeArguments.Length == 1;

            if (setLabel == null)
            {
                setLabel = GUIContentPool.Create("Arguments", "Type arguments for the generic type definition.");
            }

            int count    = genericTypeArguments.Length;
            var setValue = ArrayPool <Type> .Create(count);

            for (int n = count - 1; n >= 0; n--)
            {
                setValue[n] = GenericArgumentValues.GetValue(setGenericTypeDefinition, n);
            }

            // always set readonly to false to fix issue where
            // parameters of read-only indexer Properties could not be modified
            base.Setup(setValue, typeof(Type[]), setMemberInfo, setParent, setLabel, setReadOnly);
        }
        /// <summary>
        /// Given a non-abstract explicitly chosen type, returns the drawer for the value of the drawer using said type.
        /// </summary>
        /// <param name="typeForValue"> Type of value. </param>
        /// <returns> Drawer instance to use for the value. </returns>
        protected virtual IDrawer BuildDrawerForValue(Type typeForValue)
        {
                        #if DEV_MODE && DEBUG_DRAW_IN_SINGLE_ROW
            Debug.Log("BuildDrawerForValue(" + typeForValue.Name + ") called with DrawInSingleRow=" + DrawInSingleRow + ", CanDrawInSingleRow(" + typeForValue.Name + ")=" + DrawerUtility.CanDrawInSingleRow(typeForValue, DebugMode) + ", CanDrawMultipleControlsOfTypeInSingleRow(" + typeForValue.Name + ")=" + DrawerUtility.CanDrawMultipleControlsOfTypeInSingleRow(typeForValue));
                        #endif

                        #if DEV_MODE
            Debug.Assert(typeForValue != null);
            Debug.Assert(!typeForValue.IsGenericTypeDefinition);
                        #endif

            if (typeForValue.IsUnityObject())
            {
                return(ObjectReferenceDrawer.Create(Value as Object, memberInfo, GetTypeForObjectReferenceField(), this, GUIContent.none, AllowSceneObjects(), false, ReadOnly));
            }

            var label = GUIContentPool.Create(StringUtils.SplitPascalCaseToWords(StringUtils.ToStringSansNamespace(typeForValue)));

            // infinite loop danger!
            if (memberInfo != null && typeForValue == memberInfo.Type)
            {
                                #if DEV_MODE
                Debug.LogError("Infinite loop! typeForValue " + StringUtils.ToString(typeForValue) + " same as Type! instanceType=" + StringUtils.ToString(instanceType) + ", userSelectedType=" + StringUtils.ToString(userSelectedType));
                                #endif
                return(ReadOnlyTextDrawer.Create(StringUtils.ToString(Value), memberInfo, this, label));
            }

            return(BuildDrawerForValue(typeForValue, Value, memberInfo, this, label, ReadOnly));
        }
        private void OnDelegateValueChanged(Delegate value)
        {
                        #if DEV_MODE
            Debug.Log("OnDelegateValueChanged(" + StringUtils.ToString(value) + ")");
                        #endif

            if (value == null)
            {
                UpdateMethodOptions(null, false);
                Label = GUIContentPool.Create("null");
            }
            else
            {
                var  target      = value.Target;
                var  method      = value.Method;
                bool hasInstance = target != null;

                UpdateMethodOptions(hasInstance ? target.GetType() : method.ReflectedType, hasInstance);

                // support anonymous methods
                if (Array.IndexOf(methodOptionNames, method.Name) == -1)
                {
                    methodOptions     = methodOptions.Add(method);
                    methodOptionNames = methodOptionNames.Add(method.Name);
                }
                Label = GUIContentPool.Create("Delegate");
            }
        }
Example #7
0
        private void RebuildResultDrawer()
        {
            if (inactive)
            {
                                #if DEV_MODE
                Debug.LogWarning("Ignoring RebuildResuiltDrawer because inactive");
                                #endif
                return;
            }

            if (!hasResult)
            {
                                #if DEV_MODE
                Debug.LogWarning("Ignoring RebuildResuiltDrawer because hasResult was false");
                                #endif
                return;
            }

                        #if DEV_MODE
            Debug.Log("RebuildResultDrawer from result: " + StringUtils.ToString(base.Value));
                        #endif

            ResultDrawer = DrawerProvider.GetForField(base.Value, Type, null, this, GUIContentPool.Create("Result"), ReadOnly);
            UpdateVisibleMembers();
            drawInSingleRow = GetDrawInSingleRowUpdated();
        }
Example #8
0
            public void Setup(string setLabel, OnActivateItem setEffect, bool setOn)
            {
                label = GUIContentPool.Create(setLabel);

                effect = setEffect;
                on     = setOn;
            }
Example #9
0
        public GUIContent Get()
        {
            var result = GUIContentPool.Create(label);

            result.image = DrawGUI.IsProSkin ? imageDarkSkin : imageLightSkin;
            return(result);
        }
Example #10
0
 public void Setup(string setLabel, string setTooltip, OnActivateItemWithParameter setEffect, object setEffectParameterValue, bool setOn)
 {
     label = GUIContentPool.Create(setLabel, setTooltip);
     effectWithParameter  = setEffect;
     effectParameterValue = setEffectParameterValue;
     on = setOn;
 }
Example #11
0
        private static Type GetParameterTypeAndLabel(LinkedMemberInfo linkedMemberInfo, ref GUIContent label)
        {
            GUIContentPool.Replace(ref label, linkedMemberInfo.DisplayName, linkedMemberInfo.Tooltip);
            if (label.tooltip.Length == 0)
            {
                label.tooltip = "Parameter";
            }

            var type = linkedMemberInfo.Type;

            if (type.IsByRef)            //is ref or out
            {
                                #if DEV_MODE
                Debug.Log("isByRef: " + linkedMemberInfo + ", with IsOut=" + linkedMemberInfo.ParameterInfo.IsOut + ", Type=" + StringUtils.ToString(type) + ", elementType=" + StringUtils.ToString(type.GetElementType()));
                                #endif

                type = type.GetElementType();

                if (linkedMemberInfo.ParameterInfo.IsOut)
                {
                    label.text = string.Concat("out ", label);
                }
                else
                {
                    label.text = string.Concat("ref ", label);
                }
            }

            return(type);
        }
Example #12
0
        /// <inheritdoc/>
        public override void SetupInterface(object setValue, Type setValueType, LinkedMemberInfo setMemberInfo, IParentDrawer setParent, GUIContent setLabel, bool setReadOnly)
        {
            var      button = setMemberInfo.GetAttribute <ButtonAttribute>();
            string   setButtonText;
            GUIStyle setGUIStyle;

            if (button != null)
            {
                if (!string.IsNullOrEmpty(button.buttonText))
                {
                    setButtonText = button.buttonText;
                }
                else
                {
                    if (setLabel != null)
                    {
                        setButtonText = setLabel.text;
                    }
                    else
                    {
                        setButtonText = setMemberInfo.DisplayName;
                    }
                }

                GUIContentPool.Replace(ref setLabel, button.prefixLabelText);

                if (!string.IsNullOrEmpty(button.guiStyle))
                {
                    setGUIStyle = InspectorUtility.Preferences.GetStyle(button.guiStyle);
                    if (setGUIStyle == null)
                    {
                        setGUIStyle = InspectorPreferences.Styles.Button;
                    }
                }
                else
                {
                    setGUIStyle = InspectorPreferences.Styles.Button;
                }
            }
            else
            {
                setGUIStyle = InspectorPreferences.Styles.Button;

                if (setLabel != null)
                {
                    setButtonText = setLabel.text;
                }
                else
                {
                    setButtonText = setMemberInfo.DisplayName;
                }

                GUIContentPool.Replace(ref setLabel, "");
            }

            Setup(setMemberInfo, setParent, setLabel, GUIContentPool.Create(setButtonText), setGUIStyle, setReadOnly);
        }
Example #13
0
        /// <inheritdoc />
        protected sealed override void Setup(MulticastDelegate setValue, Type setValueType, LinkedMemberInfo setMemberInfo, IParentDrawer setParent, GUIContent setLabel, bool setReadOnly)
        {
            if (setValue == null)
            {
                if (setMemberInfo != null)
                {
                    setValue = setMemberInfo.GetValue(0) as MulticastDelegate;
                }
                else if (setValueType == null)
                {
                                        #if DEV_MODE
                    Debug.LogError("Value and fieldInfo and setDelegateType were all null for DelegateDrawer!");
                                        #endif

                    return;
                }
            }

            UpdateInvocationList(setValue);

            delegateType = setValueType;
            var type = setValueType != null ? setValueType : setMemberInfo != null ? setMemberInfo.Type : setValue.GetType();

                        #if DEV_MODE
            Debug.Assert(typeof(Delegate).IsAssignableFrom(type), type.FullName);
            Debug.Assert(type != typeof(Delegate), type.FullName + " not supported by DelegateDrawer. Should use AnyDelegateDrawer instead.");
            Debug.Assert(type != typeof(MulticastDelegate), type.FullName + " not supported by DelegateDrawer. Should use AnyDelegateDrawer instead.");
                        #endif

            var invokeMethod = type.GetMethod("Invoke");
            if (invokeMethod == null)
            {
                                #if DEV_MODE
                Debug.LogError("DelegateDrawer - Could not find \"Invoke\" method in type " + type.Name + "! memberInfo.Type=" + (setMemberInfo == null ? "n/a" : setMemberInfo.Type.Name));
                                #endif

                parameterInfos = invokeMethod.GetParameters();
            }
            else
            {
                parameterInfos = invokeMethod.GetParameters();
            }

            if (setLabel == null)
            {
                setLabel = GUIContentPool.Create(setMemberInfo == null ? "()=>" : setMemberInfo.Name, GetTooltip(parameterInfos));
            }
            else
            {
                if (setLabel.tooltip.Length == 0)
                {
                    setLabel.tooltip = GetTooltip(parameterInfos);
                }
            }

            base.Setup(setValue, setValueType, setMemberInfo, setParent, setLabel, setReadOnly);
        }
Example #14
0
        public void Dispose()
        {
            GUIContentPool.Dispose(ref label);
            onClicked = null;
            hasColor  = false;

            var disposing = this;

            pool.Dispose(ref disposing);
        }
Example #15
0
        /// <inheritdoc/>
        protected override void DoBuildMembers()
        {
                        #if DEV_MODE && DEBUG_BUILD_MEMBERS
            Debug.Log(Msg(ToString(), ".DoBuildMembers with hasResult=", hasResult, ", hasParameters=", hasParameters, ", isGeneric=", isGeneric));
                        #endif

            if (!hasResult && !hasParameters && !isGeneric)
            {
                DrawerArrayPool.Resize(ref members, 0);
            }
            else
            {
                int size = 0;
                if (hasResult)
                {
                    size++;
                }
                if (isGeneric)
                {
                    size++;
                }
                if (hasParameters)
                {
                    size++;
                }
                DrawerArrayPool.Resize(ref members, size);

                bool readOnly = ReadOnly;

                int index = 0;
                if (isGeneric)
                {
                    members[0] = GenericsDrawer.Create(memberInfo, this, GUIContentPool.Create("Generics"), readOnly);
                    index++;
                }

                if (hasParameters)
                {
                    members[index] = ParameterDrawer.Create(MethodInfo.GetParameters(), memberInfo, this, GUIContentPool.Create("Parameters"), readOnly);
                    index++;
                }

                if (hasResult)
                {
                    string tooltip = LinkedMemberInfo.TooltipDatabase.GetTooltipFromParent(MethodInfo.ReturnParameter, memberInfo, "Returns");
                    if (tooltip.Length == 0)
                    {
                        tooltip = "Value returned by method.";
                    }

                    var resultMemberInfo = resultMemberHierarchy.Get(null, typeof(MethodDrawer).GetField("result", BindingFlags.Instance | BindingFlags.NonPublic), LinkedMemberParent.ClassInstance, null);
                    members[index] = DrawerProvider.GetForField(result, Type, resultMemberInfo, this, GUIContentPool.Create("Result", tooltip), readOnly);
                }
            }
        }
Example #16
0
        /// <inheritdoc/>
        protected override void DoBuildMembers()
        {
                        #if DEV_MODE && PI_ASSERTATIONS
            Debug.Assert(memberBuildList.Count == 2);
                        #endif

            var first = Value;
            Array.Resize(ref members, 2);
            members[0] = IntDrawer.Create(first.x, memberBuildList[0], this, GUIContentPool.Create("X"), ReadOnly);
            members[1] = IntDrawer.Create(first.y, memberBuildList[1], this, GUIContentPool.Create("Y"), ReadOnly);
        }
        public static GUIContent[] Create(List <string> labelTexts)
        {
            int count  = labelTexts.Count;
            var result = Create(count);

            for (int n = count - 1; n >= 0; n--)
            {
                result[n] = GUIContentPool.Create(labelTexts[n]);
            }
            return(result);
        }
Example #18
0
        /// <inheritdoc/>
        protected override void DoBuildMembers()
        {
                        #if DEV_MODE && PI_ASSERTATIONS
            Debug.Assert(memberBuildList.Count == 3);
                        #endif

            var first = Value;
            Array.Resize(ref members, 3);
            members[0] = IntDrawer.Create(first.height, memberBuildList[0], this, GUIContentPool.Create("H"), ReadOnly);
            members[1] = IntDrawer.Create(first.width, memberBuildList[1], this, GUIContentPool.Create("W"), ReadOnly);
            members[2] = IntDrawer.Create(first.depth, memberBuildList[2], this, GUIContentPool.Create("D"), ReadOnly);
        }
Example #19
0
        /// <summary> Creates a new instance of the drawer or returns a reusable instance from the pool. </summary>
        /// <param name="buttonText"> The text to shown on the button. </param>
        /// <param name="memberInfo"> LinkedMemberInfo for the class member that the created drawer represents. Can be null. </param>
        /// <param name="parent"> The parent drawer of the created drawer. Can be null. </param>
        /// <param name="readOnly"> True if button should be greyed out and not be interactive. </param>
        /// <returns> The drawer instance, ready to be used. </returns>
        public static ButtonDrawer Create(string buttonText, LinkedMemberInfo memberInfo, IParentDrawer parent, GUIStyle style = null, bool readOnly = false)
        {
            ButtonDrawer result;

            if (!DrawerPool.TryGet(out result))
            {
                result = new ButtonDrawer();
            }
            result.Setup(GUIContentPool.Create(buttonText), null, memberInfo, parent, null, readOnly, style);
            result.LateSetup();
            return(result);
        }
Example #20
0
        public static ClassDrawer Create([NotNull] Type setClassType, [CanBeNull] IParentDrawer parent, [NotNull] IInspector inspector)
        {
            ClassDrawer result;

            if (!DrawerPool.TryGet(out result))
            {
                result = new ClassDrawer();
            }
            result.Setup(setClassType, parent, GUIContentPool.Create(StringUtils.SplitPascalCaseToWords(StringUtils.ToStringSansNamespace(setClassType))), inspector);
            result.LateSetup();
            return(result);
        }
Example #21
0
        public override void AssetHeader(Rect position, Object target)
        {
            var label = GUIContentPool.Temp(target.name.Length == 0 ? " " : target.name);
            var pos   = position;

            pos.height = AssetTitlebarHeight(false);

            pos.x     -= IndentWidth;
            pos.width += IndentWidth;

            GUI.Label(pos, label, InspectorPreferences.Styles.GameObjectHeaderBackground);
        }
Example #22
0
        /// <inheritdoc />
        protected override void DoBuildMembers()
        {
                        #if DEV_MODE && PI_ASSERTATIONS
            Debug.Assert(memberBuildList.Count == 4);
                        #endif

            var first = Value;
            Array.Resize(ref members, 4);
            members[0] = IntDrawer.Create(first.left, memberBuildList[0], this, GUIContentPool.Create("X"), false);
            members[1] = IntDrawer.Create(first.right, memberBuildList[1], this, GUIContentPool.Create("Y"), false);
            members[2] = IntDrawer.Create(first.top, memberBuildList[2], this, GUIContentPool.Create("W"), false);
            members[3] = IntDrawer.Create(first.bottom, memberBuildList[3], this, GUIContentPool.Create("H"), false);
        }
        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);
                }
            }
        }
Example #24
0
        /// <inheritdoc />
        protected override void DoBuildMembers()
        {
            bool readOnly = memberInfo != null && !memberInfo.CanWrite;

            if (readOnly)
            {
                DrawerArrayPool.Resize(ref members, 0);
            }
            else
            {
                DrawerArrayPool.Resize(ref members, 2);

                var min = TimeSpan.MinValue;
                var max = TimeSpan.MaxValue;

                var group = CustomDataSetDrawer.Create(this, GUIContentPool.Create("Days / Hours"), ReadOnly);
                {
                    var groupMembers = DrawerArrayPool.Create(2);

                    var groupMember = ClampedIntDrawer.Create(Days, min.Days, max.Days, null, group, GUIContentPool.Create("D"), ReadOnly);
                    groupMember.OnValueChanged += SetDays;
                    groupMembers[0]             = groupMember;

                    groupMember = ClampedIntDrawer.Create(Hours, MinHours, MaxHours, null, group, GUIContentPool.Create("H"), ReadOnly);
                    groupMember.OnValueChanged       += SetHours;
                    groupMember.OverrideValidateValue = ValidateHours;
                    groupMembers[1] = groupMember;

                    group.SetMembers(groupMembers, true);
                    members[0] = group;
                }

                group = CustomDataSetDrawer.Create(this, GUIContentPool.Create("Minutes / Seconds"), ReadOnly);
                {
                    var groupMembers = DrawerArrayPool.Create(2);

                    var groupMember = ClampedIntDrawer.Create(Minutes, MinMinutes, MaxMinutes, null, group, GUIContentPool.Create("M"), ReadOnly);
                    groupMember.OnValueChanged       += SetMinutes;
                    groupMember.OverrideValidateValue = ValidateMinutes;
                    groupMembers[0] = groupMember;

                    var secondsMember = ClampedFloatDrawer.Create(SecondsWithFractions, MinSeconds, MaxSeconds, null, group, GUIContentPool.Create("S"), ReadOnly);
                    secondsMember.OnValueChanged       += SetSeconds;
                    secondsMember.OverrideValidateValue = ValidateSeconds;
                    groupMembers[1] = secondsMember;

                    group.SetMembers(groupMembers, true);
                    members[1] = group;
                }
            }
        }
Example #25
0
        protected bool DrawFoldableContent(Rect position)
        {
            bool dirty = false;

            for (int n = 0; n < 3; n++)
            {
                var draw = members[n];
                if (draw.ShouldShowInInspector)
                {
                    if (draw.Draw(position))
                    {
                        dirty = true;
                    }
                    DrawGUI.NextLine(ref position);
                }
            }

            if (!UsingLocalSpace)
            {
                position.y     += 3f;
                position.height = 18f;

                if (UsingSnapping)
                {
                    position.width = 90f;
                    position.x     = (DrawGUI.InspectorWidth - (90f + 138f + 5f)) * 0.5f;
                    DrawGUI.Active.Label(position, GUIContentPool.Temp("snapping", "You can open snap settings using menu item Edit/Snap Settings..."), "WarningOverlay");

                    position.x    += 95f;
                    position.width = 138f;
                    DrawGUI.Active.Label(position, GUIContentPool.Temp("using world space", "Position, rotation and scale are listed using world space instead of local space."), "WarningOverlay");
                }
                else
                {
                    position.width = 138f;
                    position.x     = (DrawGUI.InspectorWidth - position.width) * 0.5f;

                    DrawGUI.Active.Label(position, GUIContentPool.Temp("using world space", "Position, rotation and scale are listed using world space instead of local space."), "WarningOverlay");
                }
            }
            else if (UsingSnapping)
            {
                position.y     += 3f;
                position.height = 18f;
                position.width  = 90f;
                position.x      = (DrawGUI.InspectorWidth - position.width) * 0.5f;
                DrawGUI.Active.Label(position, GUIContentPool.Temp("snapping", "You can open snap settings using menu item Edit/Snap Settings..."), "WarningOverlay");
            }

            return(dirty);
        }
Example #26
0
        /// <inheritdoc />
        protected override void Setup(Type[] setValue, Type setValueType, LinkedMemberInfo setMemberInfo, IParentDrawer setParent, GUIContent setLabel, bool setReadOnly)
        {
            memberInfo       = setMemberInfo;
            genericArguments = setMemberInfo.MethodInfo.GetGenericArguments();

            drawInSingleRow = genericArguments.Length == 1 && DrawerUtility.CanDrawMultipleControlsOfTypeInSingleRow(genericArguments[0]);

            if (setLabel == null)
            {
                setLabel = GUIContentPool.Create("Generics");
            }

            base.Setup(setValue, setValueType, setMemberInfo, setParent, setLabel, setReadOnly);
        }
Example #27
0
        /// <inheritdoc/>
        protected override void DoBuildMembers()
        {
                        #if DEV_MODE && PI_ASSERTATIONS
            Debug.Assert(memberBuildList.Count == 4);
                        #endif

            var first = Value;
            Array.Resize(ref members, 4);
            var readOnly = ReadOnly;
            members[0] = FloatDrawer.Create(first.x, memberBuildList[0], this, GUIContentPool.Create("X"), readOnly);
            members[1] = FloatDrawer.Create(first.y, memberBuildList[1], this, GUIContentPool.Create("Y"), readOnly);
            members[2] = FloatDrawer.Create(first.width, memberBuildList[2], this, GUIContentPool.Create("W"), readOnly);
            members[3] = FloatDrawer.Create(first.height, memberBuildList[3], this, GUIContentPool.Create("H"), readOnly);
        }
Example #28
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);
                    }
                }
            }
        }
Example #29
0
        protected override void DoBuildMembers()
        {
            Array.Resize(ref members, 26);

            var first = Value;

            bool readOnly = ReadOnly;

            //NOTE: This didn't have a LinkedMemberInfo earlier for some reason. Did it cause problems?
            members[0] = TextDrawer.Create(first.name, memberBuildList[0], this, GUIContentPool.Create("Name"), readOnly, false);

            members[1] = GUIStyleStateDrawer.Create(first.normal, memberBuildList[1], this, GUIContentPool.Create("Normal"), readOnly);
            members[2] = GUIStyleStateDrawer.Create(first.hover, memberBuildList[2], this, GUIContentPool.Create("Hover"), readOnly);
            members[3] = GUIStyleStateDrawer.Create(first.active, memberBuildList[3], this, GUIContentPool.Create("Active"), readOnly);
            members[4] = GUIStyleStateDrawer.Create(first.focused, memberBuildList[4], this, GUIContentPool.Create("Focused"), readOnly);

            members[5] = GUIStyleStateDrawer.Create(first.onNormal, memberBuildList[5], this, GUIContentPool.Create("On Normal"), readOnly);
            members[6] = GUIStyleStateDrawer.Create(first.onHover, memberBuildList[6], this, GUIContentPool.Create("On Hover"), readOnly);
            members[7] = GUIStyleStateDrawer.Create(first.onActive, memberBuildList[7], this, GUIContentPool.Create("On Active"), readOnly);
            members[8] = GUIStyleStateDrawer.Create(first.onFocused, memberBuildList[8], this, GUIContentPool.Create("On Focused"), readOnly);

            members[9]  = RectOffsetDrawer.Create(first.border, memberBuildList[9], this, GUIContentPool.Create("Border"), readOnly);
            members[10] = RectOffsetDrawer.Create(first.margin, memberBuildList[10], this, GUIContentPool.Create("Margin"), readOnly);
            members[11] = RectOffsetDrawer.Create(first.padding, memberBuildList[11], this, GUIContentPool.Create("Padding"), readOnly);
            members[12] = RectOffsetDrawer.Create(first.overflow, memberBuildList[12], this, GUIContentPool.Create("Overflow"), readOnly);

            members[13] = ObjectReferenceDrawer.Create(first.font, memberBuildList[13], this, GUIContentPool.Create("Font"), true, false, readOnly);
            members[14] = IntDrawer.Create(first.fontSize, memberBuildList[14], this, GUIContentPool.Create("Font Size"), readOnly);
            members[15] = EnumDrawer.Create(first.fontStyle, memberBuildList[15], this, GUIContentPool.Create("Font Style"), readOnly);

            members[16] = EnumDrawer.Create(first.alignment, memberBuildList[16], this, GUIContentPool.Create("Alignment"), readOnly);
            members[17] = ToggleDrawer.Create(first.wordWrap, memberBuildList[17], this, GUIContentPool.Create("Word Wrap"), readOnly);
            members[18] = ToggleDrawer.Create(first.richText, memberBuildList[18], this, GUIContentPool.Create("Rich Text"), readOnly);
            members[19] = EnumDrawer.Create(first.clipping, memberBuildList[19], this, GUIContentPool.Create("Text Clipping"), readOnly);

            members[20] = EnumDrawer.Create(first.imagePosition, memberBuildList[20], this, GUIContentPool.Create("Image Position"), readOnly);
            members[21] = Vector2Drawer.Create(first.contentOffset, memberBuildList[21], this, GUIContentPool.Create("Content Offset"), readOnly);
            members[22] = FloatDrawer.Create(first.fixedWidth, memberBuildList[22], this, GUIContentPool.Create("Fixed Width"), readOnly);
            members[23] = FloatDrawer.Create(first.fixedHeight, memberBuildList[23], this, GUIContentPool.Create("Fixed Height"), readOnly);
            members[24] = ToggleDrawer.Create(first.stretchWidth, memberBuildList[24], this, GUIContentPool.Create("Strech Width"), readOnly);
            members[25] = ToggleDrawer.Create(first.stretchHeight, memberBuildList[25], this, GUIContentPool.Create("Strech Height"), readOnly);

                        #if DEV_MODE
            Debug.Assert(memberBuildList.Count == members.Length);
                        #endif
        }
Example #30
0
        /// <inheritdoc/>
        public override void SetMembers(IDrawer[] setMembers, bool sendVisibilityChangedEvents = true)
        {
                        #if DEV_MODE
            Debug.Log(ToString() + ".SetMembers(" + StringUtils.ToString(setMembers) + ")");
                        #endif

                        #if DEV_MODE && PI_ASSERTATIONS
            Debug.Assert(!Array.Exists(setMembers, member => member == null));
                        #endif

            inactive = false;
            UpdatePrefixDrawer();

            base.SetMembers(setMembers, sendVisibilityChangedEvents);

            int count = members.Length;
                        #if UNITY_EDITOR
            UnityEditor.EditorGUIUtility.SetIconSize(new Vector2(IconWidth, IconWidth));
                        #endif

            icons = new GUIContent[count];
            for (int n = 0; n < count; n++)
            {
                                #if UNITY_EDITOR
                var member = members[n];
                var target = member.UnityObject;
                if (target != null)
                {
                    var content = UnityEditor.EditorGUIUtility.ObjectContent(target, null);
                    var icon    = GUIContentPool.Create(content.image, member.Name);
                    icons[n] = icon;
                }
                else
                                #endif
                {
                    icons[n] = GUIContentPool.Create(Inspector.Preferences.graphics.missingAssetIcon);
                }
            }

            //widthNeededToDrawAllIcons = count * IconOffset;

                        #if DEV_MODE && PI_ASSERTATIONS
            Debug.Assert(memberBuildState == MemberBuildState.MembersBuilt);
                        #endif
        }