void OnGUI() { GUILayout.Space(10); if (GameObject.Find("JournalCanvas") == null) { EditorGUILayout.LabelField("Installation Required", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(EditorStyles.helpBox); EditorGUILayout.LabelField("Clicking install will create the required Journal components.", EditorStyles.centeredGreyMiniLabel, GUILayout.Height(50)); GUI.color = new Color32(76, 180, 255, 255); if (GUILayout.Button(new GUIContent("✔ Install Journal", "Automatically install journal's components"), GUILayout.Height(50))) { if (GameObject.Find("JournalCanvas") == null) { PrefabUtility.InstantiatePrefab(Resources.Load <GameObject>("Prefabs/JournalCanvas")); Debug.Log("Journal was installed. Journal should only be installed in the first scene you want achievement tracking in as it will carry over to loaded scenes."); } else { Debug.LogWarning("An instance of Journal is already installed. To remove it, simply delete the JournalCanvas object."); } if (FindObjectOfType <UnityEngine.EventSystems.EventSystem>() == null) { Debug.Log("An EventSystem was created as one was not detected in your scene."); PrefabUtility.InstantiatePrefab(Resources.Load <UnityEngine.EventSystems.EventSystem>("Prefabs/EventSystem")); } editorHandler.SaveFromEditor(tempAchievementList); AssetDatabase.Refresh(); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); } EditorGUILayout.LabelField("Tools", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent("Undo", "Undo unsaved changes"), GUILayout.Height(35))) { editorHandler = new EditorAchievementHandler(); tempAchievementList = new List <Achievement>(editorHandler.LoadAchievementFile()); } if (GUILayout.Button(new GUIContent("0 all stats", "Reset all achievement values to 0"), GUILayout.Height(35))) { ResetAllStats(); } if (GUILayout.Button(new GUIContent("Generate IDs", "Automatically generate IDs for ALL achievements, starting from 0"), GUILayout.Height(35))) { GenerateIDs(); } if (GUILayout.Button(new GUIContent("Close all", "Close all open achievement editors"), GUILayout.Height(35))) { for (int i = 0; i < showAchievementDetails.Count; i++) { showAchievementDetails[i] = false; } } GUI.color = new Color32(255, 145, 165, 255); if (GUILayout.Button(new GUIContent("Delete Player Save", "Remove the saved achievement data"), GUILayout.Height(35))) { Journal.DeleteSave(); } GUI.color = Color.white; EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); DrawAchievementsArea(); DrawControlArea(); }
void Awake() { editorHandler = new EditorAchievementHandler(); tempAchievementList = editorHandler.LoadAchievementFile(); }