Esempio n. 1
0
        public override void OnInspectorGUI()
        {
            Datasack ds = (Datasack)target;

            DrawDefaultInspector();

            EditorGUILayout.BeginVertical();

            if (GUILayout.Button("CODEGEN"))
            {
                GenerateCode();
            }

            GUILayout.Space(20);

            if (GUILayout.Button("RUNTIME POKE"))
            {
                ds.Poke();
            }

            GUILayout.Space(20);

            if (GUILayout.Button("RUNTIME TOGGLE"))
            {
                ds.bValue = !ds.bValue;
            }

            GUILayout.Space(20);

            GUI.color = Color.green;
            if (GUILayout.Button("RESET TO INITIAL VALUE"))
            {
                ds.Value = ds.InitialValue;
            }

            GUILayout.Space(20);

            GUI.color = Color.cyan;
            if (GUILayout.Button("OUTPUT CURRENT VALUE"))
            {
                string part1 = "Datasack " + ds.FullName + " is currently: '" + ds.Value + "'";
                string part2 = " <not parseable as float>";
                try
                {
                    part2 = "--> as float value = " + ds.fValue;
                }
                catch { }                               // gotta catch 'em all: fairly harmless in a small context
                Debug.Log(part1 + part2);
            }

            GUILayout.Space(20);

            GUI.color = Color.yellow;
            if (GUILayout.Button("DELETE SAVED VALUE"))
            {
                if (PlayerPrefs.HasKey(PlayerPrefsKey()))
                {
                    PlayerPrefs.DeleteKey(PlayerPrefsKey());
                    PlayerPrefs.Save();
                }
            }

            GUILayout.Space(20);

            GUI.color = Color.red;
            if (GUILayout.Button("DELETE ALL PLAYER PREFS"))
            {
                if (EditorUtility.DisplayDialog("CONFIRM!",
                                                "Confirm DELETE all PlayerPrefs stored settings?\n\n" +
                                                "(THIS ACTION CANNOT BE UNDONE!)", "DELETE ALL PREFS", "Cancel"))
                {
                    DSM.ResetDictionaryIfRunning();
                    PlayerPrefs.DeleteAll();
                    PlayerPrefs.Save();
                }
            }

            GUILayout.Space(20);

            GUI.color = ds.DebugBreak ? Color.white : Color.gray;

            GUILayout.BeginHorizontal();
            GUILayout.Label("Debug Break", GUILayout.Width(160));
            ds.DebugBreak = GUILayout.Toggle(ds.DebugBreak, "BREAK");
            GUILayout.EndHorizontal();

            GUI.color = ds.DebugLogging ? Color.white : Color.gray;

            GUILayout.BeginHorizontal();
            GUILayout.Label("Debug Logging", GUILayout.Width(160));
            ds.DebugLogging = GUILayout.Toggle(ds.DebugLogging, "LOG");
            GUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }
Esempio n. 2
0
        public override void OnInspectorGUI()
        {
            Datasack ds = (Datasack)target;

            DrawDefaultInspector();

            EditorGUILayout.BeginVertical();

            if (GUILayout.Button("CODEGEN"))
            {
                GenerateCode();
            }

            GUILayout.Space(20);

            if (GUILayout.Button("RUNTIME POKE"))
            {
                ds.Poke();
            }

            GUILayout.Space(20);

            if (GUILayout.Button("RUNTIME TOGGLE"))
            {
                ds.bValue = !ds.bValue;
            }

            GUILayout.Space(20);

            GUI.color = Color.green;
            if (GUILayout.Button("RESET TO INITIAL VALUE"))
            {
                ds.Value = ds.InitialValue;
            }

            GUILayout.Space(20);

            GUI.color = Color.cyan;
            if (GUILayout.Button("OUTPUT CURRENT VALUE"))
            {
                Debug.Log(ds.DisplayDebugOutput());
            }

            GUILayout.Space(20);

            GUI.color = Color.yellow;
            if (GUILayout.Button("DELETE SAVED VALUE"))
            {
                if (PlayerPrefs.HasKey(PlayerPrefsKey()))
                {
                    PlayerPrefs.DeleteKey(PlayerPrefsKey());
                    PlayerPrefs.Save();
                }
            }

            GUILayout.Space(20);

            GUI.color = Color.red;
            if (GUILayout.Button("DELETE ALL PLAYER PREFS"))
            {
                if (EditorUtility.DisplayDialog("CONFIRM!",
                                                "Confirm DELETE all PlayerPrefs stored settings?\n\n" +
                                                "(THIS ACTION CANNOT BE UNDONE!)", "DELETE ALL PREFS", "Cancel"))
                {
                    DSM.ResetDictionaryIfRunning();
                    PlayerPrefs.DeleteAll();
                    PlayerPrefs.Save();
                }
            }

            GUILayout.Space(20);

            GUI.color = ds.DebugBreak ? Color.white : Color.gray;

            GUILayout.BeginHorizontal();
            GUILayout.Label("Debug Break", GUILayout.Width(160));
            ds.DebugBreak = GUILayout.Toggle(ds.DebugBreak, "BREAK");
            GUILayout.EndHorizontal();

            GUI.color = ds.DebugLogging ? Color.white : Color.gray;

            GUILayout.BeginHorizontal();
            GUILayout.Label("Debug Logging", GUILayout.Width(160));
            ds.DebugLogging = GUILayout.Toggle(ds.DebugLogging, "LOG");
            GUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }