public void SetTheme(BabbelEditorTheme theme = null) { if (theme == null) { theme = AssetTools.LoadByQuery <BabbelEditorTheme>("t:BabbelEditorTheme"); } if (theme == null) { AssetTools.EnsureFolder(defaultThemeLocation); theme = AssetTools.CreateAsset <BabbelEditorTheme>(defaultThemeLocation);; } titleContent = new GUIContent(GetBabbelName(), theme.BabbelLogo); _theme = theme; }
void AddEditArea() { if (editTag == null) { if (GUILayout.Button(theme.Add, theme.UpStateToggle)) { AssetTools.EnsureFolder(defaultTagLocation); editTag = AssetTools.CreateAsset <Tag>(defaultTagLocation);; } } else { EditorGUI.BeginChangeCheck(); editTagNewName = EditorGUILayout.TextField(string.IsNullOrEmpty(editTagNewName) ? editTag.name : editTagNewName, theme.Title); if (EditorGUI.EndChangeCheck()) { editTagNameChange = true; } editTagNewDescription = EditorGUILayout.TextField(string.IsNullOrEmpty(editTagNewDescription) ? editTag.description : editTagNewDescription, theme.Text); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(theme.SaveClose, theme.UpStateToggle)) { SaveEditTag(); ClearEditTagEdit(); } else if (GUILayout.Button(theme.Save, theme.UpStateToggle)) { SaveEditTag(); ClearEditTagEdit(true); } else if (GUILayout.Button(theme.Close, theme.UpStateToggle)) { ClearEditTagEdit(); } else if (GUILayout.Button(theme.Delete, theme.UpStateToggle)) { AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(editTag)); ClearEditTagEdit(); } EditorGUILayout.EndHorizontal(); } }
void AddMenu() { if (GUI.Button(menuPosition, theme.Menu, expandedMenu ? theme.TitleAcitveIconAligning : theme.TitleIconAligning)) { expandedMenu = !expandedMenu; } expandedMenuPosition.width = maxSize.x - (4 + expandedMenuPosition.x); GUILayout.BeginArea(expandedMenuPosition); if (expandedMenu) { //ACTS GUILayout.BeginHorizontal(); if (GUILayout.Button(theme.StoryActs, theme.Title)) { activeAct = null; activeScene = null; editActiveActName = null; } foreach (StoryAct act in Story.acts) { bool isTheActiveAct = act == activeAct && activeAct != null; if (isTheActiveAct && editActiveActName != null) { editActiveActName = GUILayout.TextField(editActiveActName, theme.IconAligningInput); if (GUILayout.Button(theme.SaveIcon, theme.Title)) { AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(activeAct), editActiveActName); editActiveActName = null; } } else if (GUILayout.Button(act.name, isTheActiveAct ? theme.TitleAcitveIconAligning : theme.TitleIconAligning)) { if (isTheActiveAct) { editActiveActName = act.name; } else { activeAct = act; editActiveActName = null; } activeScene = null; } } if (GUILayout.Button(theme.AddIcon, theme.Title)) { string newActPath = AssetDatabase.GetAssetPath(Story); if (!string.IsNullOrEmpty(newActPath)) { newActPath += "_Acts/"; AssetTools.EnsureFolder(newActPath); activeAct = AssetTools.CreateAsset <StoryAct>(newActPath); Story.acts.Add(activeAct); editActiveActName = activeAct.name; } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); //SCENES GUILayout.BeginHorizontal(); if (GUILayout.Button(theme.StoryScenes, theme.Title)) { activeScene = null; editAcitveSceneName = null; } if (activeAct != null) { foreach (Scene scene in activeAct.All <Scene>()) { bool isTheActiveScene = scene == activeScene && activeScene != null; if (isTheActiveScene && editAcitveSceneName != null) { editAcitveSceneName = GUILayout.TextField(editAcitveSceneName, theme.Input); if (GUILayout.Button(theme.SaveIcon, theme.Title)) { AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(activeScene), editAcitveSceneName); editAcitveSceneName = null; } } else if (GUILayout.Button(scene.name, isTheActiveScene ? theme.TitleAcitveIconAligning : theme.TitleIconAligning)) { if (isTheActiveScene) { editAcitveSceneName = scene.name; } else { activeScene = scene; editAcitveSceneName = null; } } } } if (GUILayout.Button(theme.AddIcon, activeAct == null ? theme.DownStateToggle : theme.Title)) { //Only allow adding scenes when we are in an act! if (activeAct != null) { string newScenePath = AssetDatabase.GetAssetPath(Story); if (!string.IsNullOrEmpty(newScenePath)) { newScenePath += "_Scenes/"; AssetTools.EnsureFolder(newScenePath); activeScene = AssetTools.CreateAsset <Scene>(newScenePath); activeAct.scenes.Add(activeScene); editAcitveSceneName = activeScene.name; } } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal(); if (activeAct == null) { GUILayout.Label(theme.NoAct, theme.TitleAcitveIconAligning); } else { GUILayout.Label(activeAct.name, activeScene == null ? theme.TitleAcitveIconAligning : theme.TitleIconAligning); if (activeScene != null) { GUILayout.Label(activeScene.name, theme.TitleAcitveIconAligning); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } GUILayout.FlexibleSpace(); GUILayout.EndArea(); }