Exemplo n.º 1
0
    void OnGUI()
    {
        if (spawn.unitList[currentLevel] == null)
        {
            spawn.unitList[currentLevel]       = new SpawnableClass();
            spawn.unitList[currentLevel].level = level;
        }

        GUILayout.Label("Units for: ");
        level = (UnitLevels)EditorGUILayout.EnumPopup(level);
        if (GUILayout.Button("Add Unit"))
        {
            Resize(ref spawn.unitList[currentLevel].units, 1);
        }
        scrollbar = EditorGUILayout.BeginScrollView(scrollbar);
        {
            if (spawn.unitList[currentLevel].units.Length > 0)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("Units");
                EditorGUILayout.EndHorizontal();
                for (int x = 0; x < spawn.unitList[currentLevel].units.Length; x++)
                {
                    EditorGUILayout.BeginHorizontal();
                    spawn.unitList[currentLevel].units[x] = (GameObject)EditorGUILayout.ObjectField(spawn.unitList[currentLevel].units[x], typeof(GameObject), false);
                    if (GUILayout.Button("X", GUILayout.MaxWidth(20)))
                    {
                        RemoveAt(ref spawn.unitList[currentLevel].units, x);
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            else
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("No units set for current unit level.");
                EditorGUILayout.EndHorizontal();
            }
        }
        EditorGUILayout.EndScrollView();
        if (GUI.changed)
        {
            currentLevel = (int)level;
            EditorUtility.SetDirty(spawn);
        }
    }