protected override void OnEnable()
        {
            useOrderedDrawersProperty = serializedObject.FindProperty("useOrderedDrawers");

            presetHandlersList   = ToolboxEditorUtility.CreateBoxedList(serializedObject.FindProperty("presetHandlers"));
            propertyHandlersList = ToolboxEditorUtility.CreateBoxedList(serializedObject.FindProperty("propertyHandlers"));
        }
Пример #2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            EditorGUILayout.PropertyField(useToolboxHierarchyProperty);
            EditorGUILayout.PropertyField(useToolboxDrawersProperty);
            if (useToolboxDrawersProperty.boolValue)
            {
                EditorGUILayout.HelpBox("Select all wanted drawers and press \"Apply\" button.", MessageType.Info);
                areaDrawerHandlersList.DoLayoutList();
                EditorGUILayout.Separator();
                EditorGUILayout.HelpBox("Work in progress.", MessageType.Warning);
                EditorGUI.BeginDisabledGroup(true);
                groupDrawerHandlersList.DoLayoutList();
                EditorGUI.EndDisabledGroup();
                EditorGUILayout.Separator();
                propertyDrawerHandlersList.DoLayoutList();
                EditorGUILayout.Separator();
                conditionDrawerHandlersList.DoLayoutList();
            }
            serializedObject.ApplyModifiedProperties();

            EditorGUILayout.Space();
            EditorGUILayout.Space();
            if (GUILayout.Button(Style.buttonContent, Style.buttonOptions))
            {
                ToolboxEditorUtility.ReimportEditor();
            }
        }
Пример #3
0
            /// <summary>
            /// Draw property using Unity's layouting system and created <see cref="ToolboxDrawer"/>s.
            /// </summary>
            public void OnGui()
            {
                //begin all needed area drawers in proper order
                for (var i = 0; i < areaAttributes.Length; i++)
                {
                    ToolboxEditorUtility.GetAreaDrawer(areaAttributes[i])?.OnGuiBegin(areaAttributes[i]);
                }

                //handle condition attribute(only one allowed)
                var conditionState = PropertyCondition.Valid;

                if (conditionAttribute != null)
                {
                    conditionState = ToolboxEditorUtility.GetConditionDrawer(conditionAttribute)?.OnGuiValidate(property, conditionAttribute) ?? conditionState;
                }

                if (conditionState == PropertyCondition.NonValid)
                {
                    //end all area drawers without drawing property
                    for (var i = areaAttributes.Length - 1; i >= 0; i--)
                    {
                        ToolboxEditorUtility.GetAreaDrawer(areaAttributes[i])?.OnGuiEnd(areaAttributes[i]);
                    }
                    return;
                }

                if (conditionState == PropertyCondition.Disabled)
                {
                    EditorGUI.BeginDisabledGroup(true);
                }

                //get property attribute(only one allowed)
                if (propertyAttribute != null)
                {
                    ToolboxEditorUtility.GetPropertyDrawer(propertyAttribute)?.OnGui(property, propertyAttribute);
                }
                else
                {
                    EditorGUILayout.PropertyField(property, property.isExpanded);
                }

                //end disabled state check
                if (conditionState == PropertyCondition.Disabled)
                {
                    EditorGUI.EndDisabledGroup();
                }

                //end all needed area drawers in proper order
                for (var i = areaAttributes.Length - 1; i >= 0; i--)
                {
                    ToolboxEditorUtility.GetAreaDrawer(areaAttributes[i])?.OnGuiEnd(areaAttributes[i]);
                }
            }
Пример #4
0
        /// <summary>
        /// Draws <see cref="ReorderableList"/> if provided property is previously cached array/list.
        /// </summary>
        /// <param name="property">Property to draw.</param>
        /// <param name="attribute"></param>
        public override void HandleProperty(SerializedProperty property, ReorderableListAttribute attribute)
        {
            if (!reorderableLists.ContainsKey(property.name))
            {
                reorderableLists[property.name] = ToolboxEditorUtility.CreateList(property,
                                                                                  attribute.ListStyle,
                                                                                  attribute.ElementLabel,
                                                                                  attribute.FixedSize,
                                                                                  attribute.Draggable);
            }

            reorderableLists[property.name].DoLayoutList();
        }
Пример #5
0
 public override void HandleProperty(SerializedProperty property, OrderedLineAttribute attribute)
 {
     ToolboxEditorUtility.DrawLayoutLine(attribute.Thickness, attribute.Padding);
     base.HandleProperty(property, attribute);
 }