public static void Init() { // Get existing open window or if none, make a new one: var window = (Rme_Main)GetWindow(typeof(Rme_Main)); //window.maxSize = new Vector2(1050, 500); window.titleContent = new GUIContent("RPG AIO"); window.minSize = new Vector2(950.1F, 530.1F); window.position = new Rect(200, 200, 950.1F, 530.1F); Window = window; Pages = Enum.GetValues(typeof(CurrentPage)) as CurrentPage[]; EditorGameDataSaveLoad.LoadIfNotLoadedFromEditor(); }
private void OnGUIx() { GUI.skin = Resources.Load("RPGMakerAssets/EditorSkinRPGMaker") as GUISkin; GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Space(1); GUILayout.Label("Prefab Browser", "mainTitle", GUILayout.Height(40)); GUILayout.Space(1); GUILayout.EndHorizontal(); GUILayout.Space(2); GUILayout.BeginHorizontal(); GUILayout.Space(2); #region "Categories" GUILayout.BeginVertical("backgroundBox", GUILayout.Width(180), GUILayout.ExpandHeight(true)); GUILayout.Label("Categories"); var categories = Enum.GetNames(typeof(Rmh_PrefabType)); var ifShowAll = showAll ? "listItemSelected" : "listItem"; if (GUILayout.Button("All", ifShowAll, GUILayout.Height(25))) { showAll = true; return; } foreach (var cat in categories) { var ifSelected = selectedCategory.ToString() == cat && !showAll ? "listItemSelected" : "listItem"; if (GUILayout.Button(cat.Replace('_', ' '), ifSelected, GUILayout.Height(25))) { selectedCategory = (Rmh_PrefabType)Enum.Parse(typeof(Rmh_PrefabType), cat); showAll = false; return; } } GUILayout.EndVertical(); #endregion GUILayout.Space(2); #region "MainArea" GUILayout.BeginVertical("backgroundBoxMain"); GUILayout.BeginHorizontal(); GUILayout.Label("Filter:", GUILayout.Width(35)); GUI.SetNextControlName("searchTerm"); _searchTerm = GUILayout.TextField(_searchTerm, "nodeTextField", GUILayout.Width(200)); GUILayout.Space(1); if (!showAll && !new [] { Rmh_PrefabType.Enemy, Rmh_PrefabType.NPC, Rmh_PrefabType.Harvest }.Any(c => c == selectedCategory)) { if (GUILayout.Button("+ Create New", "genericButton", GUILayout.Height(25))) { if (selectedCategory == Rmh_PrefabType.Skill) { Rme_PrefabGenerator.GeneratePrefab(selectedCategory, selectedSkillType); } else { Rme_PrefabGenerator.GeneratePrefab(selectedCategory); } UpdatePrefabs(); } if (selectedCategory == Rmh_PrefabType.Skill) { selectedSkillType = (SkillType)RPGMakerGUI.EnumPopup("Skill Type:", selectedSkillType); } } else if (!showAll) { if (GUILayout.Button("+ Create New In RPGMaker", "genericButton", GUILayout.Height(25))) { Rme_Main.Init(); } } GUILayout.EndHorizontal(); if (Event.current.type == EventType.Repaint) { if (GUI.GetNameOfFocusedControl() == "searchTerm" && _searchTerm == _searchTermPlaceholder) { _searchTerm = ""; } } List <PrefabInfo> objectsFiltered = objects; if (_searchTerm != _searchTermPlaceholder) { if (showAll) { objectsFiltered = objects.Where(o => o.Identifier != null && ((o.Identifier.SearchName.ToLower().Contains(_searchTerm.ToLower()) || o.Identifier.PrefabType.ToString().ToLower().Contains(_searchTerm.ToLower()))) ).ToList(); } else { objectsFiltered = objects.Where(o => o.Identifier != null && ((o.Identifier.SearchName.ToLower().Contains(_searchTerm.ToLower()) || o.Identifier.PrefabType.ToString().ToLower().Contains(_searchTerm.ToLower())) && o.Identifier.PrefabType == selectedCategory) ).ToList(); } } content = objectsFiltered.Select(s => new GUIContent(s.Identifier.SearchName + (showTriangles ? s.Details : ""), s.Preview)).ToArray(); scrollPos = GUILayout.BeginScrollView(scrollPos); selectedObjectIndex = GUILayout.SelectionGrid(selectedObjectIndex, content, Window.position.width > 520 ? (int)((Window.position.width - 520) / 120).RoundToNearest(1) : 1, "prefabWindowGrid"); if (selectedObjectIndex > content.Length - 1) { selectedObjectIndex = 0; } var oldSelectedObject = selectedObject; selectedObject = selectedObjectIndex != -1 && objectsFiltered.Count > 0 ? objectsFiltered[selectedObjectIndex] : null; if (selectedObject != oldSelectedObject) { GUI.FocusControl(""); } GUILayout.EndScrollView(); GUILayout.EndVertical(); #endregion GUILayout.Space(2); #region "Properties" GUILayout.BeginVertical("backgroundBox", GUILayout.Width(200), GUILayout.ExpandHeight(false)); GUILayout.Space(5); GUILayout.BeginHorizontal(); GUILayout.Space(5); GUILayout.BeginVertical(); GUILayout.Label("Properties"); if (selectedObject != null) { if (selectedObject.Identifier != null) { EditorGUILayout.PrefixLabel("Name:"); selectedObject.Identifier.SearchName = EditorGUILayout.TextField(selectedObject.Identifier.SearchName); EditorGUILayout.PrefixLabel("Type:"); selectedObject.Identifier.PrefabType = (Rmh_PrefabType)EditorGUILayout.EnumPopup(selectedObject.Identifier.PrefabType); EditorGUILayout.LabelField(selectedObject.Identifier.PrefabType.ToString()); if (GUILayout.Button("Spawn To Scene", "genericButton", GUILayout.Height(25))) { var obj = AssetDatabase.LoadAssetAtPath <GameObject>(selectedObject.Path); GeneralMethodsEditor.InstantiateInView(obj); } if (GUILayout.Button("Select in Project Folder", "genericButton", GUILayout.Height(25))) { var obj = AssetDatabase.LoadAssetAtPath <GameObject>(selectedObject.Path); Selection.activeObject = obj; Selection.activeGameObject = obj; } } } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); #endregion GUILayout.Space(2); GUILayout.EndHorizontal(); GUILayout.Space(2); GUILayout.BeginHorizontal("backgroundBox", GUILayout.Height(30)); GUILayout.Space(5); if (GUILayout.Button("Reload Prefabs", "genericButton", GUILayout.Height(25))) { objects = new List <PrefabInfo>(); UpdatePrefabs(); return; } if (GUILayout.Button("Toggle Tri. Count", "genericButton", GUILayout.Height(25))) { showTriangles = !showTriangles; } GUILayout.FlexibleSpace(); GUILayout.Label(objectsFiltered.Count + " Items", GUILayout.Width(120)); GUILayout.EndHorizontal(); GUILayout.EndVertical(); }
private void OnGUIx() { GUI.skin = Resources.Load("RPGMakerAssets/EditorSkinRPGMaker") as GUISkin; if (Window.position.width > 600) { GUILayout.BeginHorizontal(); } else { GUILayout.BeginVertical(); } if (GUILayout.Button(new GUIContent("RPGAIO", RPGMakerGUI.RPGMakerIcon), "rpgToolBarButton")) { Rme_Main.Init(); } if (GUILayout.Button(new GUIContent("Prefab Window", PrefabBrowserIcon), "rpgToolBarButton")) { Rme_Tools_PrefabRepository.Init(); } if (GUILayout.Button(new GUIContent("Save Data", SaveIcon), "rpgToolBarButton")) { EditorGameDataSaveLoad.SaveGameData(); } if (GUILayout.Button(new GUIContent("Reload Data", LoadIcon), "rpgToolBarButton")) { EditorGameDataSaveLoad.LoadGameDataFromEditor(); } if (GUILayout.Button(new GUIContent("Combat", CombatIcon), "rpgToolBarButton")) { CombatNodeWindow.Init(); } if (GUILayout.Button(new GUIContent("Dialog", DialogIcon), "rpgToolBarButton")) { DialogNodeWindow.Init(); } if (GUILayout.Button(new GUIContent("Events", EventIcon), "rpgToolBarButton")) { EventNodeWindow.Init(); } if (GUILayout.Button(new GUIContent("Achievements", AchievementIcon), "rpgToolBarButton")) { AchievementNodeWindow.Init(); } if (GUILayout.Button(new GUIContent("Map", MapIcon), "rpgToolBarButton")) { WorldMapNodeWindow.Init(); } if (GUILayout.Button(new GUIContent("New Scene", NewSceneIcon), "rpgToolBarButton")) { AddScene(); } if (GUILayout.Button(new GUIContent("Event Trigger", EventTriggerIcon), "rpgToolBarButton")) { EventTrigger(); } if (GUILayout.Button(new GUIContent("Level Switch", LevelSwitchIcon), "rpgToolBarButton")) { LevelSwitch(); } if (GUILayout.Button(new GUIContent("Popup Text", PopupTextIcon), "rpgToolBarButton")) { PopupText(); } GUILayout.EndHorizontal(); }
public void OnEnable() { Window = this; EditorGameDataSaveLoad.LoadIfNotLoadedFromEditor(); }
public static void Main(Rect fullArea, Rect leftArea, Rect mainArea, Rme_Main window) { GUI.Box(fullArea, "", "backgroundBox"); GUILayout.BeginArea(fullArea); GUILayout.BeginVertical(); if(GUILayout.Button("Add Skill")) { Windows.Add(new VisualiserWindow() { ID = Windows.Count > 0 ? (Windows.Max(i => i.ID) + 1) : 0, SkillID = "", Type = VisualiserType.Skill, rect = new Rect(Random.Range(50,100+1),Random.Range(50,100+1),50,50), Area = 1 }); } if(GUILayout.Button("Add Horizontal")) { Windows.Add(new VisualiserWindow() { ID = Windows.Count > 0 ? (Windows.Max(i => i.ID) + 1) : 0, SkillID = "", Type = VisualiserType.Hori, rect = new Rect(Random.Range(50,100+1),Random.Range(50,100+1),25,10), Area = 1 }); } if(GUILayout.Button("Add Vertical")) { Windows.Add(new VisualiserWindow() { ID = Windows.Count > 0 ? (Windows.Max(i => i.ID) + 1) : 0, SkillID = "", Type = VisualiserType.Vert, rect = new Rect(Random.Range(50,100+1),Random.Range(50,100+1),10,25), Area = 1 }); } GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Box("",GUILayout.Width(300),GUILayout.Height(500)); var toRectA = GUILayoutUtility.GetLastRect(); GUILayout.FlexibleSpace(); GUILayout.Box("", GUILayout.Width(300), GUILayout.Height(500)); var toRectB = GUILayoutUtility.GetLastRect(); GUILayout.FlexibleSpace(); GUILayout.Box("", GUILayout.Width(300), GUILayout.Height(500)); var toRectC = GUILayoutUtility.GetLastRect(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.EndVertical(); window.BeginWindows(); for (int i = 0; i < Windows.Count; i++) { var windowData = Windows[i]; Rect rect; switch(windowData.Area) { case 0: rect = toRectA; break; case 1: rect = toRectB; break; case 2: rect = toRectC; break; default: rect = toRectA; break; } windowData.rect = RoundWindow(ClampWindow(GUILayout.Window(windowData.ID, windowData.rect, myWindow, "", "visualiserWindow_" + windowData.Type.ToString()), rect)); } window.EndWindows(); GUILayout.EndArea(); }