コード例 #1
0
        protected bool DrawGroupTitle(FieldInfo p_fieldInfo, ref int p_groupIndex, ref string p_lastGroup, bool p_initializeMinimized, GUIStyle p_style)
        {
            TitledGroupAttribute ga = p_fieldInfo?.GetCustomAttribute <TitledGroupAttribute>();
            string currentGroup     = ga != null ? ga.Group : "Properties";

            if (currentGroup != p_lastGroup)
            {
                int groupMask = 1 << p_groupIndex;
                p_groupIndex++;
                if (p_initializeMinimized && ga != null && ga.Minimized && (groupsMinized & groupMask) == 0)
                {
                    groupsMinized += groupMask;
                }

                GUIPropertiesUtils.Separator(16, 2, 4, new Color(0.1f, 0.1f, 0.1f));
                GUILayout.Label(currentGroup, DashEditorCore.Skin.GetStyle("PropertyGroup"));

                Rect lastRect = GUILayoutUtility.GetLastRect();

                bool isMinimized = (groupsMinized & groupMask) != 0;
                if (GUI.Button(new Rect(lastRect.x, lastRect.y - 25, lastRect.width, 20), "", p_style))
                {
                    groupsMinized = isMinimized ? groupsMinized - groupMask : groupsMinized + groupMask;
                }

                GUI.Label(new Rect(lastRect.x + 356 + (isMinimized ? 0 : 2), lastRect.y - 25, 20, 20), isMinimized ? "+" : "-", p_style);

                p_lastGroup = currentGroup;
            }

            return((groupsMinized & (1 << (p_groupIndex - 1))) != 0);
        }
コード例 #2
0
        public virtual bool DrawInspector()
        {
            bool initializeMinimization = false;

            if (groupsMinized == -1)
            {
                initializeMinimization = true;
                groupsMinized          = 0;
            }

            GUILayout.Space(5);

            GUIStyle minStyle = GUIStyle.none;

            minStyle.normal.textColor = Color.white;
            minStyle.fontStyle        = FontStyle.Bold;
            minStyle.fontSize         = 16;

            var fields = this.GetType().GetFields();

            Array.Sort(fields, GUIPropertiesUtils.GroupSort);
            string lastGroup          = "";
            bool   lastGroupMinimized = false;
            bool   invalidate         = false;
            int    groupIndex         = 0;

            if (GetType().GetCustomAttribute <CustomInspectorAttribute>() != null)
            {
                lastGroupMinimized = DrawGroupTitle(null, ref groupIndex, ref lastGroup, initializeMinimization, minStyle);
                if (!lastGroupMinimized)
                {
                    DrawCustomInspector();
                }
            }

            foreach (var field in fields)
            {
                if (field.IsConstant() || !GUIPropertiesUtils.MeetsDependencies(field, this) || GUIPropertiesUtils.IsHidden(field))
                {
                    continue;
                }

                lastGroupMinimized = DrawGroupTitle(field, ref groupIndex, ref lastGroup, initializeMinimization, minStyle);

                if (lastGroupMinimized)
                {
                    continue;
                }

                invalidate = invalidate || GUIPropertiesUtils.PropertyField(field, this, this);
            }

            return(invalidate);
        }
コード例 #3
0
        public void ValidateSerialization()
        {
            var fields = this.GetType().GetFields();

            foreach (var field in fields)
            {
                if (!GUIPropertiesUtils.IsParameterProperty(field))
                {
                    continue;
                }

                if ((Parameter)field.GetValue(this) == null)
                {
                    RecreateParameter(field);
                }
            }
        }
コード例 #4
0
        public override bool DrawInspector()
        {
            bool invalidate = false;

            if (preset != null)
            {
                GUILayout.Space(5);

                GUIPropertiesUtils.Separator(16, 2, 4, new Color(0.1f, 0.1f, 0.1f));
                GUILayout.Label("Preset Properties", DashEditorCore.Skin.GetStyle("PropertyGroup"),
                                GUILayout.Width(120));
                Rect lastRect = GUILayoutUtility.GetLastRect();

                GUIStyle minStyle = GUIStyle.none;
                minStyle.normal.textColor = Color.white;
                minStyle.fontSize         = 16;
                if (GUI.Button(new Rect(lastRect.x + 302, lastRect.y - 25, 20, 20), _presetGroupMinimzed ? "+" : "-",
                               minStyle))
                {
                    _presetGroupMinimzed = !_presetGroupMinimzed;
                }

                if (!_presetGroupMinimzed)
                {
                    var fields = preset.GetType().GetFields();

                    foreach (var field in fields)
                    {
                        if (field.IsConstant())
                        {
                            continue;
                        }
                        invalidate = GUIPropertiesUtils.PropertyField(field, preset, this);
                    }
                }
            }

            bool invalidateBase = base.DrawInspector();

            return(invalidate || invalidateBase);
        }
コード例 #5
0
        public virtual bool DrawInspector()
        {
            bool initializeMinimization = false;

            if (groupsMinized == -1)
            {
                initializeMinimization = true;
                groupsMinized          = 0;
            }

            GUILayout.Space(5);

            GUIStyle minStyle = GUIStyle.none;

            minStyle.normal.textColor = Color.white;
            minStyle.fontSize         = 16;

            var fields = this.GetType().GetFields();

            Array.Sort(fields, GUIPropertiesUtils.GroupSort);
            string lastGroup          = "";
            bool   lastGroupMinimized = false;
            bool   invalidate         = false;
            int    groupIndex         = 0;

            foreach (var field in fields)
            {
                if (field.IsConstant())
                {
                    continue;
                }

                TitledGroupAttribute ga = field.GetCustomAttribute <TitledGroupAttribute>();
                string currentGroup     = ga != null ? ga.Group : "Properties";
                if (currentGroup != lastGroup)
                {
                    int groupMask = (int)Math.Pow(2, groupIndex);
                    groupIndex++;
                    if (initializeMinimization && ga != null && ga.Minimized && (groupsMinized & groupMask) == 0)
                    {
                        groupsMinized += groupMask;
                    }

                    GUIPropertiesUtils.Separator(16, 2, 4, new Color(0.1f, 0.1f, 0.1f));
                    GUILayout.Label(currentGroup, DashEditorCore.Skin.GetStyle("PropertyGroup"),
                                    GUILayout.Width(120));
                    Rect lastRect = GUILayoutUtility.GetLastRect();


                    if (GUI.Button(new Rect(lastRect.x + 302, lastRect.y - 25, 20, 20), (groupsMinized & groupMask) != 0 ? "+" : "-",
                                   minStyle))
                    {
                        groupsMinized = (groupsMinized & groupMask) == 0
                            ? groupsMinized + groupMask
                            : groupsMinized - groupMask;
                    }

                    lastGroup          = currentGroup;
                    lastGroupMinimized = (groupsMinized & groupMask) != 0;
                }

                if (lastGroupMinimized)
                {
                    continue;
                }

                invalidate = invalidate || GUIPropertiesUtils.PropertyField(field, this, null);
            }

            if (invalidate)
            {
                DashEditorCore.SetDirty();
            }

            return(invalidate);
        }