private void OnGUI() { bool was = CustomHierarchyData.On; CustomHierarchyData.On = EditorGUILayout.Toggle("Enable : ", CustomHierarchyData.On); if (CustomHierarchyData.On != was) { EditorApplication.RepaintHierarchyWindow(); } if (GUILayout.Button("Load")) { CustomHierarchyData.Load(); } if (GUILayout.Button("Save")) { CustomHierarchyData.Save(); } GUILayout.BeginHorizontal(); if (currentTab == Tab.Main) { if (GUILayout.Button("Main", new GUIStyle() { fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleCenter }, GUILayout.Width(100))) { } if (GUILayout.Button("Options", GUILayout.Width(100))) { currentTab = Tab.Option; } } else { if (GUILayout.Button("Main", GUILayout.Width(100))) { currentTab = Tab.Main; } if (GUILayout.Button("Options", new GUIStyle() { fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleCenter }, GUILayout.Width(100))) { } } GUILayout.EndHorizontal(); if (currentTab == Tab.Main) { DrawMain(); } else { DrawOptions(); } }
void DrawOptions() { EditorGUILayout.BeginHorizontal(); CustomizeHierarchy.PathToFolder = EditorGUILayout.TextField("Path to folders : ", CustomizeHierarchy.PathToFolder); if (GUILayout.Button("Default")) { CustomizeHierarchy.PathToFolder = "Assets\\CustomEditor\\styles"; } EditorGUILayout.EndHorizontal(); GUILayout.Label("Choosed style : " + CustomizeHierarchy.FileName); if (GUILayout.Button("Add new profile")) { string name = "Profile"; if (Directory.Exists(CustomizeHierarchy.PathToFolder) == false) { Debug.LogError("Can't find directory for styles"); return; } if (File.Exists(CustomizeHierarchy.PathToFolder + "/" + name + ".opt")) { int i = 1; name += "1"; while (File.Exists(CustomizeHierarchy.PathToFolder + "/" + name + ".opt")) { name = name.Replace(i.ToString(), (i + 1).ToString()); i++; } } File.Create(CustomizeHierarchy.PathToFolder + "/" + name + ".opt"); } foreach (string file in fileList) { GUILayout.BeginHorizontal(); if (GUILayout.Button(file, GUILayout.Width(100))) { AssetDatabase.Refresh(); CustomizeHierarchy.FileName = file; CustomHierarchyData.Load(); CustomHierarchyData.Save(); } GUILayout.Space(40); if (GUILayout.Button("DEL", GUILayout.Width(50))) { AssetDatabase.Refresh(); if (File.Exists(CustomizeHierarchy.PathToFolder + "/" + file)) { File.Delete(CustomizeHierarchy.PathToFolder + "/" + file); AssetDatabase.Refresh(); } } GUILayout.EndHorizontal(); } }