Ejemplo n.º 1
0
 public override void Init()
 {
     base.Init();
     bank.SaveAsDefaults();
     Load();
     CompleteInit();
 }
Ejemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            //base.OnInspectorGUI();
            InputBank bank = target as InputBank;

            //Create List
            if (bank.keys == null)
            {
                bank.keys = new List <Key>();
            }

            //Keys
            for (int i = 0; i < bank.keys.Count; i++)
            {
                if (i >= bank.keys.Count)
                {
                    continue;
                }

                Key key = bank.keys[i];

                key.openInInspector = EditorGUILayout.Foldout(key.openInInspector, "key: " + key.GetName());

                if (key.openInInspector)
                {
                    key.SetName(EditorGUILayout.TextField("name", key.GetName()));
                    key.SetKeyCode((KeyCode)EditorGUILayout.EnumPopup("KeyCode", key.GetKeyCode()));
                    GUILayout.BeginHorizontal();
                    if (!Application.isPlaying && GUILayout.Button("Remove", GUILayout.Width(100)))
                    {
                        bank.keys.Remove(key); // Remove Key
                    }
                    if (GUILayout.Button("^", GUILayout.Width(30)))
                    {
                        bank.MoveBy(key, -1); // Move up
                    }//
                    if (GUILayout.Button("v", GUILayout.Width(30)))
                    {
                        bank.MoveBy(key, 1); // Move down
                    }

                    GUILayout.EndHorizontal();
                    EditorGUILayout.Space();
                }
            }

            //Add Key
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            if (!Application.isPlaying && GUILayout.Button("Add Key"))
            {
                bank.keys.Add(new Key("", KeyCode.Asterisk)); // Add
            }
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            GUILayout.BeginHorizontal();
            if (!Application.isPlaying && GUILayout.Button("Save as defaults"))
            {
                bank.SaveAsDefaults();
                AssetDatabase.SaveAssets();
                Debug.LogWarning("Default keys saved to: " + Application.persistentDataPath + InputBank.defaultKeysPath);
            }

            if (!Application.isPlaying && GUILayout.Button("Load from defaults"))
            {
                bank.LoadDefaults();
                Debug.LogWarning("Default keys loaded from: " + Application.persistentDataPath + InputBank.defaultKeysPath);
            }

            if (!Application.isPlaying && GUILayout.Button("Clear defaults"))
            {
                bank.ClearDefaults();
                Debug.LogWarning("Default keys loaded from: " + Application.persistentDataPath + InputBank.defaultKeysPath);
            }
            GUILayout.EndHorizontal();

            EditorUtility.SetDirty(bank);
        }