protected bool AddElementButton(Rect position, SerializedProperty property, AddElementCallback addElementCallback = null)
    {
        bool pressed = false;

        if (AddElementButton(position))
        {
            AddElement(property, addElementCallback);
            pressed = true;
        }
        return(pressed);
    }
    protected SerializedProperty AddElement(SerializedProperty property, AddElementCallback addElementCallback = null)
    {
        property.arraySize += 1;
        property.serializedObject.ApplyModifiedProperties();
        EditorUtility.SetDirty(property.serializedObject.targetObject);

        SerializedProperty newProperty = property.GetArrayElementAtIndex(property.arraySize - 1);

        if (addElementCallback != null)
        {
            addElementCallback(newProperty);
        }

        return(newProperty);
    }
Exemple #3
0
        protected bool LargeAddElementButton(GUIContent label, AddElementCallback addElementCallback = null)
        {
            bool pressed = false;

            GUILayout.BeginHorizontal();
            EditorGUI.BeginDisabledGroup(Application.isPlaying);
            GUILayout.Space(EditorGUI.indentLevel * 16);
            GUIStyle style = new GUIStyle("MiniToolbarButton");

            if (GUILayout.Button(label, style))
            {
                pressed = true;
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();
            return(pressed);
        }
Exemple #4
0
        protected bool AddElementFoldOut(SerializedProperty property, GUIContent label, GUIStyle style, int overrideArraySize, AddElementCallback addElementCallback = null)
        {
            int arraySize = property.arraySize;

            if (overrideArraySize >= 0)
            {
                arraySize = overrideArraySize;
            }
            label.text += string.Format(" ({0})", arraySize);

            EditorGUILayout.BeginHorizontal();

            if (property.isExpanded && arraySize == 0)
            {
                property.isExpanded = false;
            }

            property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, label, style);

            bool pressed = false;

            if (property.isExpanded && arraySize == 0)
            {
                AddElement(property, addElementCallback);
                pressed = true;
            }

            if (AddElementButton(property, addElementCallback))
            {
                pressed = true;
            }

            EditorGUILayout.EndHorizontal();
            return(pressed);
        }
Exemple #5
0
        protected bool LargeAddElementButton(SerializedProperty property, GUIContent label, AddElementCallback addElementCallback = null)
        {
            bool pressed = false;

            if (LargeAddElementButton(label, addElementCallback))
            {
                AddElement(property, addElementCallback);
                pressed = true;
            }
            return(pressed);
        }
Exemple #6
0
 protected bool AddElementFoldOut(SerializedProperty property, bool showing, string label, AddElementCallback addElementCallback = null)
 {
     return(AddElementFoldOut(property, showing, new GUIContent(label), -1, addElementCallback));
 }
Exemple #7
0
        protected bool AddElementFoldOut(SerializedProperty property, bool showing, GUIContent label, int overrideArraySize, AddElementCallback addElementCallback = null)
        {
            int arraySize = property.arraySize;

            if (overrideArraySize >= 0)
            {
                arraySize = overrideArraySize;
            }
            label.text += string.Format(" ({0})", arraySize);

            EditorGUILayout.BeginHorizontal();
            if (showing && arraySize == 0)
            {
                showing = false;
            }
            showing = EditorGUILayout.Foldout(showing, label);
            if (showing && arraySize == 0)
            {
                AddElement(property, addElementCallback);
            }
            AddElementButton(property, addElementCallback);
            EditorGUILayout.EndHorizontal();
            return(showing);
        }
Exemple #8
0
 protected bool AddElementFoldOut(SerializedProperty property, GUIContent label, AddElementCallback addElementCallback = null)
 {
     return(AddElementFoldOut(property, label, EditorStyles.foldout, -1, addElementCallback));
 }
Exemple #9
0
 protected bool AddElementFoldOut(SerializedProperty property, GUIContent label, GUIStyle style, AddElementCallback addElementCallback = null)
 {
     return(AddElementFoldOut(property, label, style, -1, addElementCallback));
 }