Exemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        if (kb.keys == null || kb.keyCodes == null)
        {
            kb.keys     = new InputKey[0];
            kb.keyCodes = new KeyCode[0];
        }

        EditorGUILayout.BeginVertical();

        //BUTTONS
        if (GUILayout.Button("Add Element"))
        {
            //add element
            kb.count++;
            kb.keys     = ArrayEX.ResizeArray(kb.count, kb.keys);
            kb.keyCodes = ArrayEX.ResizeArray(kb.count, kb.keyCodes);
        }
        if (GUILayout.Button("Remove Element"))
        {
            //remove last element
            if (kb.count > 0)
            {
                kb.count--;
                kb.keys     = ArrayEX.ResizeArray(kb.count, kb.keys);
                kb.keyCodes = ArrayEX.ResizeArray(kb.count, kb.keyCodes);
            }
        }
        if (GUILayout.Button("Reset"))
        {
            kb.count    = 0;
            kb.keys     = new InputKey[kb.count];
            kb.keyCodes = new KeyCode[kb.count];
        }

        for (int i = 0; i < kb.count; i++)
        {
            kb.keys[i]     = (InputKey)EditorGUILayout.EnumPopup("Key", kb.keys[i]);
            kb.keyCodes[i] = (KeyCode)EditorGUILayout.EnumPopup("KeyCode", kb.keyCodes[i]);
            EditorGUILayout.Space();
        }

        EditorGUILayout.EndVertical();
        EditorUtility.SetDirty(kb);
    }
Exemplo n.º 2
0
    private void Load()
    {
        EditorGUILayout.LabelField("Load Scenes", EditorStyles.boldLabel);
        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("Add", GUILayout.MaxWidth(250)))
        {
            sl.loadCount++;
            sl.loadScenes = ArrayEX.ResizeArray(sl.loadCount, sl.loadScenes);
            sl.loadNames  = ArrayEX.ResizeArray(sl.loadCount, sl.loadNames);
        }
        if (GUILayout.Button("Remove", GUILayout.MaxWidth(350)))
        {
            if (sl.loadCount > 0)
            {
                sl.loadCount--;
                sl.loadScenes = ArrayEX.ResizeArray(sl.loadCount, sl.loadScenes);
                sl.loadNames  = ArrayEX.ResizeArray(sl.loadCount, sl.loadNames);
            }
        }
        if (GUILayout.Button("Reset", GUILayout.MaxWidth(250)))
        {
            sl.loadCount  = 0;
            sl.loadScenes = ArrayEX.ResizeArray(sl.loadCount, sl.loadScenes);
            sl.loadNames  = ArrayEX.ResizeArray(sl.loadCount, sl.loadNames);
        }

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space(16);

        if (sl.loadCount > 0)
        {
            for (int i = 0; i < sl.loadCount; i++)
            {
                sl.loadScenes[i] = EditorGUILayout.ObjectField(sl.loadScenes[i], typeof(Object), true);
                if (sl.loadScenes[i] != null)
                {
                    sl.loadNames[i] = sl.loadScenes[i].name;
                    //EditorGUILayout.TextField(sl.names[i]);
                }
            }
        }
    }
Exemplo n.º 3
0
    private void Unload()
    {
        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("Add"))
        {
            sl.unloadCount++;
            sl.unloadScenes = ArrayEX.ResizeArray(sl.unloadCount, sl.unloadScenes);
            sl.unloadNames  = ArrayEX.ResizeArray(sl.unloadCount, sl.unloadNames);
        }
        if (GUILayout.Button("Remove"))
        {
            if (sl.loadCount > 0)
            {
                sl.unloadCount--;
                sl.unloadScenes = ArrayEX.ResizeArray(sl.unloadCount, sl.unloadScenes);
                sl.unloadNames  = ArrayEX.ResizeArray(sl.unloadCount, sl.unloadNames);
            }
        }
        if (GUILayout.Button("Reset"))
        {
            sl.unloadCount  = 0;
            sl.unloadScenes = ArrayEX.ResizeArray(sl.unloadCount, sl.unloadScenes);
            sl.unloadNames  = ArrayEX.ResizeArray(sl.unloadCount, sl.unloadNames);
        }

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space(16);

        if (sl.unloadCount > 0)
        {
            for (int i = 0; i < sl.unloadCount; i++)
            {
                sl.unloadScenes[i] = EditorGUILayout.ObjectField(sl.unloadScenes[i], typeof(Object), true);
                if (sl.unloadScenes[i] != null)
                {
                    sl.unloadNames[i] = sl.unloadScenes[i].name;
                    //EditorGUILayout.TextField(sl.names[i]);
                }
            }
        }
    }
Exemplo n.º 4
0
 public void AddGoblin()
 {
     goblins = ArrayEX.ResizeArray(goblins.Length + 1, goblins);
 }