Exemplo n.º 1
0
        private void PaintCharactersList(SerializedProperty characters)
        {
            EditorGUILayout.BeginVertical(CoreGUIStyles.GetHelpBox());

            int removeIndex   = -1;
            int numCharacters = characters.arraySize;

            for (int i = 0; i < numCharacters; ++i)
            {
                SerializedProperty element       = characters.GetArrayElementAtIndex(i);
                GUIContent         targetContent = new GUIContent(string.Format("Character {0}", i));

                EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
                EditorGUILayout.PropertyField(element, targetContent);
                if (GUILayout.Button("-", EditorStyles.miniButton, GUILayout.Width(25f)))
                {
                    removeIndex = i;
                }

                EditorGUILayout.EndHorizontal();
            }

            if (GUILayout.Button("+"))
            {
                characters.InsertArrayElementAtIndex(numCharacters);
            }

            if (removeIndex != -1)
            {
                characters.DeleteArrayElementAtIndex(removeIndex);
            }

            EditorGUILayout.EndVertical();
        }