Exemplo n.º 1
0
        public override void Draw(PropertyData data)
        {
            //data.Attributes.ForEach(a => EditorGUILayout.LabelField(a.GetType().FullName));

            var attr = data.Attributes.FirstOrDefault() as StructDrawerAttribute;

            if (attr == null)
            {
                attr = new StructDrawerAttribute();
            }

            switch (data.Parent != null ? attr.ItemType : StructDrawerAttribute.ItemTypes.None)
            {
            case StructDrawerAttribute.ItemTypes.FadeGroup:
                //EditorGUILayout.GetControlRect(false, 10, GUILayout.Width(8));
                EditorGUILayout.BeginVertical();
                AnimBool animBool = Editor.GetAnimBool(data.Property.propertyPath, data.Property.isExpanded);
                //data.Property.isExpanded = EditorGUILayout.Foldout(data.Property.isExpanded, new GUIContent(data.Property.displayName));

                if (EditorGUILayout.DropdownButton(new GUIContent(data.Property.displayName), FocusType.Passive,
                                                   data.Property.isExpanded ? Style.FoldoutExpanded : Style.Foldout))
                {
                    data.Property.isExpanded = !data.Property.isExpanded;
                }

                animBool.target = data.Property.isExpanded;
                if (EditorGUILayout.BeginFadeGroup(animBool.faded))
                {
                    EditorGUI.indentLevel++;
                    DrawProperies(data);
                    EditorGUI.indentLevel--;
                }

                EditorGUILayout.EndFadeGroup();
                EditorGUILayout.EndVertical();
                break;

            case StructDrawerAttribute.ItemTypes.Box:
                EditorGUILayout.BeginVertical(Style.ListItemBox);
                DrawProperies(data);
                EditorGUILayout.EndVertical();
                break;

            case StructDrawerAttribute.ItemTypes.HorizontalGroup:
                EditorGUILayout.BeginHorizontal();
                DrawProperies(data);
                EditorGUILayout.EndHorizontal();
                break;

            default:
                EditorGUILayout.BeginVertical();
                DrawProperies(data);
                EditorGUILayout.EndVertical();
                break;
            }
        }
Exemplo n.º 2
0
        public override void Draw(PropertyData data)
        {
            //data.Attributes.ForEach(a => EditorGUILayout.LabelField(a.GetType().FullName));
            StructDrawerAttribute attr = null;

            if (data.Parent != null && data.Parent.Type == PropertyData.Types.List)
            {
                attr = data.Parent.Attributes.FirstOrDefault(e => e is StructDrawerAttribute) as StructDrawerAttribute;
            }
            if (attr == null)
            {
                attr = data.Attributes.FirstOrDefault(e => e is StructDrawerAttribute) as StructDrawerAttribute;
            }
            if (attr == null)
            {
                attr = new StructDrawerAttribute();
            }

            switch (data.Parent != null ? attr.ItemType : StructDrawerAttribute.ItemTypes.None)
            {
            case StructDrawerAttribute.ItemTypes.FadeGroup:
                //EditorGUILayout.GetControlRect(false, 10, GUILayout.Width(8));
                EditorGUILayout.BeginVertical();
                //data.Property.isExpanded = EditorGUILayout.Foldout(data.Property.isExpanded, new GUIContent(data.Property.displayName));

                if (EditorGUILayout.DropdownButton(new GUIContent(data.Property.displayName), FocusType.Passive,
                                                   data.Property.isExpanded ? Style.FoldoutExpanded : Style.Foldout))
                {
                    data.Property.isExpanded = !data.Property.isExpanded;
                }

                if (data.Property.isExpanded)
                {
                    int lastIndent = EditorGUI.indentLevel;
                    EditorGUI.indentLevel = 1;
                    DrawProperies(data);
                    EditorGUI.indentLevel = lastIndent;
                }

                EditorGUILayout.EndVertical();
                break;

            case StructDrawerAttribute.ItemTypes.Box:
                EditorGUILayout.BeginVertical(Style.ListItemBox);
                DrawProperies(data);
                EditorGUILayout.EndVertical();
                break;

            case StructDrawerAttribute.ItemTypes.HorizontalGroup:
                EditorGUILayout.BeginHorizontal();
                DrawProperies(data);
                EditorGUILayout.EndHorizontal();
                break;

            default:
                EditorGUILayout.BeginVertical();
                DrawProperies(data);
                EditorGUILayout.EndVertical();
                break;
            }
        }