public static void Show_MainEditorWindow() { BloxEdGlobal.CheckAllData(); MainEditorWindow window = EditorWindow.GetWindow <MainEditorWindow>("BGS"); Texture2D image = plyEdGUI.LoadTextureResource("BloxEditor.res.icons.bgs" + (plyEdGUI.IsDarkSkin() ? "_p" : "") + ".png", typeof(MainEditorWindow).Assembly, FilterMode.Point, TextureWrapMode.Clamp); window.titleContent = new GUIContent("BGS", image); }
public override void OnGUI() { if ((UnityEngine.Object) this.bootstrap == (UnityEngine.Object)null) { if (this.canTryLoadBootstrap && Event.current.type == EventType.Repaint) { this.canTryLoadBootstrap = false; this.bootstrap = plyEdUtil.LoadPrefab <Bootstrap>(BloxEdGlobal.BootstrapFabPath); GUIUtility.ExitGUI(); } else if (plyEdGUI.MessageButton(MainEditorPanel.GC_FixError, MainEditorPanel.STR_BootstrapError1, MessageType.Error)) { this.canTryLoadBootstrap = true; BloxEdGlobal.CheckBootstrap(); GUIUtility.ExitGUI(); } } else { EditorGUILayout.BeginHorizontal(); if (plyEdGUI.Menu(ref MainEditorPanel.menuIdx, ref this.scroll[0], MainEditorPanel.menuLabels, new GUILayoutOption[1] { GUILayout.Width(150f) })) { switch (MainEditorPanel.menuIdx) { case 0: this.SelectedStartupSettings(); break; case 1: this.SelectedPropertiesManager(); break; case 2: this.SelectGlobalVars(); break; case 3: this.SelectedSettings(); break; case 5: this.edAttributeDefinitions.OnSelected(base.editorWindow); break; case 6: this.edManagedImages.OnSelected(base.editorWindow); break; } } EditorGUILayout.BeginVertical(); EditorGUILayout.Space(); switch (MainEditorPanel.menuIdx) { case 0: this.DrawStartupSettings(); break; case 1: this.DrawPropertiesManager(); break; case 2: this.DrawGlobalVars(); break; case 3: this.DrawSettings(); break; case 5: this.edAttributeDefinitions.Draw(base.editorWindow); break; case 6: this.edManagedImages.Draw(base.editorWindow); break; } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } }
private void DrawStartupSettings() { EditorGUILayout.BeginHorizontal(); GUILayout.Label(MainEditorPanel.GC_GameScenes, plyEdGUI.Styles.HeadLabel); EditorGUILayout.Space(); plyEdHelpManager.Button("blox-scenes"); EditorGUILayout.Space(); if (GUILayout.Button(MainEditorPanel.GC_AddScene, plyEdGUI.Styles.BigButtonFlat)) { string text = EditorUtility.OpenFilePanel("Select Scene", plyEdUtil.ProjectFullPath + "Assets/", "unity"); if (!string.IsNullOrEmpty(text)) { text = plyEdUtil.ProjectRelativePath(text); plyEdUtil.AddSceneToBuildSettings(text, false); } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); GUILayout.Space(10f); this.scroll[1] = EditorGUILayout.BeginScrollView(this.scroll[1]); if (EditorBuildSettings.scenes.Length == 0) { if (plyEdGUI.MessageButton(MainEditorPanel.GC_FixError, MainEditorPanel.STR_BootstrapError2, MessageType.Error)) { BloxEdGlobal.CheckBootstrap(); GUIUtility.ExitGUI(); return; } } else { int num = -1; int num2 = -1; int num3 = -1; int num4 = -1; for (int i = 0; i < EditorBuildSettings.scenes.Length; i++) { if (i == 0 && (EditorBuildSettings.scenes[i].path != BloxEdGlobal.BootstrapScenePath || !EditorBuildSettings.scenes[i].enabled)) { if (!plyEdGUI.MessageButton(MainEditorPanel.GC_FixError, MainEditorPanel.STR_BootstrapError2, MessageType.Error)) { break; } this.canTryLoadBootstrap = true; BloxEdGlobal.CheckBootstrap(); GUIUtility.ExitGUI(); return; } if (EditorBuildSettings.scenes[i].enabled) { GUI.enabled = (i != 0); EditorGUILayout.BeginHorizontal(); string text2 = EditorBuildSettings.scenes[i].path.Substring(7, EditorBuildSettings.scenes[i].path.Length - 13); if (i == 0) { GUILayout.Label(MainEditorPanel.GC_AutoloadBootstrap, plyEdGUI.Styles.ButtonLeft, GUILayout.Width(25f)); GUILayout.Label(MainEditorPanel.GC_AutoloadBootstrap, plyEdGUI.Styles.ButtonMid, GUILayout.Width(25f)); } else { int num5 = this.bootstrap.startupScenes.IndexOf(i); MainEditorPanel.GC_StartupOrder.text = ((num5 >= 0) ? (num5 + 1).ToString() : " "); if (GUILayout.Button(MainEditorPanel.GC_StartupOrder, plyEdGUI.Styles.ButtonLeft, GUILayout.Width(25f))) { num = i; } if (GUILayout.Button(this.bootstrap.autoloadScenes.Contains(i) ? MainEditorPanel.GC_AutoLoad_ON : MainEditorPanel.GC_AutoLoad_OFF, plyEdGUI.Styles.ButtonMid, GUILayout.Width(25f))) { num2 = i; } } if (GUILayout.Button(text2, plyEdGUI.Styles.ButtonMid_LeftText, GUILayout.Width(375f)) && EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) { EditorSceneManager.OpenScene(EditorBuildSettings.scenes[i].path, OpenSceneMode.Single); if (SceneView.sceneViews.Count > 0) { ((SceneView)SceneView.sceneViews[0]).Focus(); } } if (GUILayout.Button(MainEditorPanel.GC_RenameScene, plyEdGUI.Styles.ButtonMid, GUILayout.Width(30f))) { num4 = i; } if (GUILayout.Button(MainEditorPanel.GC_RemoveScene, plyEdGUI.Styles.ButtonRight, GUILayout.Width(30f))) { num3 = i; } EditorGUILayout.EndHorizontal(); GUI.enabled = true; } } if (num3 >= 1) { plyEdUtil.RemoveSceneFromBuildSettings(num3); } if (num4 >= 1) { plyTextInputWiz.ShowWiz("Rename Scene", "Enter unique name for scene", plyEdUtil.SceneNameFromPath(EditorBuildSettings.scenes[num4].path), this.OnRenameScene, new object[1] { num4 }, 250f); } if (num >= 1) { if (this.bootstrap.startupScenes.Contains(num)) { this.bootstrap.startupScenes.Remove(num); } else { this.bootstrap.startupScenes.Add(num); } plyEdUtil.SetDirty(this.bootstrap); } if (num2 >= 1) { if (this.bootstrap.autoloadScenes.Contains(num2)) { this.bootstrap.autoloadScenes.Remove(num2); } else { this.bootstrap.autoloadScenes.Add(num2); } plyEdUtil.SetDirty(this.bootstrap); } } EditorGUILayout.Space(); Rect rect = GUILayoutUtility.GetRect(470f, 35f, plyEdGUI.Styles.DropArea, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false)); GUI.Box(rect, MainEditorPanel.GC_DropScenes, plyEdGUI.Styles.DropArea); Event current = Event.current; if (current.type == EventType.DragUpdated && rect.Contains(current.mousePosition)) { if (DragAndDrop.objectReferences.Length != 0 && DragAndDrop.objectReferences[0].GetType() == typeof(SceneAsset)) { DragAndDrop.visualMode = DragAndDropVisualMode.Generic; current.Use(); } else { DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; } } EventType _ = current.type; if (current.type == EventType.DragPerform && rect.Contains(current.mousePosition) && DragAndDrop.objectReferences.Length != 0 && DragAndDrop.objectReferences[0].GetType() == typeof(SceneAsset)) { int num6 = 0; while (num6 < DragAndDrop.objectReferences.Length && num6 < DragAndDrop.paths.Length) { if (DragAndDrop.objectReferences[num6].GetType() == typeof(SceneAsset)) { plyEdUtil.AddSceneToBuildSettings(DragAndDrop.paths[num6], false); } num6++; } DragAndDrop.AcceptDrag(); current.Use(); } EditorGUILayout.EndScrollView(); }
private void DrawStartupSettings() { EditorGUILayout.BeginHorizontal(); GUILayout.Label(MainEditorPanel.GC_GameScenes, plyEdGUI.Styles.HeadLabel); EditorGUILayout.Space(); plyEdHelpManager.Button("blox", "scenes"); EditorGUILayout.Space(); if (GUILayout.Button(MainEditorPanel.GC_AddScene, plyEdGUI.Styles.BigButtonFlat)) { string text = EditorUtility.OpenFilePanel("Select Scene", plyEdUtil.ProjectFullPath + "Assets/", "unity"); if (!string.IsNullOrEmpty(text)) { text = plyEdUtil.ProjectRelativePath(text); plyEdUtil.AddSceneToBuildSettings(text, false); } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); GUILayout.Space(10f); if (EditorBuildSettings.scenes.Length == 0) { if (plyEdGUI.MessageButton(MainEditorPanel.GC_FixError, MainEditorPanel.STR_BootstrapError2, MessageType.Error)) { BloxEdGlobal.CheckBootstrap(); GUIUtility.ExitGUI(); } } else { int num = -1; int num2 = -1; int num3 = -1; int num4 = -1; for (int i = 0; i < EditorBuildSettings.scenes.Length; i++) { if (i == 0 && (EditorBuildSettings.scenes[i].path != BloxEdGlobal.BootstrapScenePath || !EditorBuildSettings.scenes[i].enabled)) { if (!plyEdGUI.MessageButton(MainEditorPanel.GC_FixError, MainEditorPanel.STR_BootstrapError2, MessageType.Error)) { break; } this.canTryLoadBootstrap = true; BloxEdGlobal.CheckBootstrap(); GUIUtility.ExitGUI(); return; } if (EditorBuildSettings.scenes[i].enabled) { GUI.enabled = (i != 0); EditorGUILayout.BeginHorizontal(); string text2 = EditorBuildSettings.scenes[i].path.Substring(7, EditorBuildSettings.scenes[i].path.Length - 13); if (i == 0) { GUILayout.Label(MainEditorPanel.GC_AutoloadBootstrap, plyEdGUI.Styles.ButtonLeft, GUILayout.Width(25f)); GUILayout.Label(MainEditorPanel.GC_AutoloadBootstrap, plyEdGUI.Styles.ButtonMid, GUILayout.Width(25f)); } else { int num5 = this.bootstrap.startupScenes.IndexOf(i); MainEditorPanel.GC_StartupOrder.text = ((num5 >= 0) ? (num5 + 1).ToString() : " "); if (GUILayout.Button(MainEditorPanel.GC_StartupOrder, plyEdGUI.Styles.ButtonLeft, GUILayout.Width(25f))) { num = i; } if (GUILayout.Button(this.bootstrap.autoloadScenes.Contains(i) ? MainEditorPanel.GC_AutoLoad_ON : MainEditorPanel.GC_AutoLoad_OFF, plyEdGUI.Styles.ButtonMid, GUILayout.Width(25f))) { num2 = i; } } if (GUILayout.Button(text2, MainEditorPanel.Styles.ButtonMid_LeftText, GUILayout.Width(375f)) && EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) { EditorSceneManager.OpenScene(EditorBuildSettings.scenes[i].path, OpenSceneMode.Single); if (SceneView.sceneViews.Count > 0) { ((SceneView)SceneView.sceneViews[0]).Focus(); } } if (GUILayout.Button(MainEditorPanel.GC_RenameScene, plyEdGUI.Styles.ButtonMid, GUILayout.Width(30f))) { num4 = i; } if (GUILayout.Button(MainEditorPanel.GC_RemoveScene, plyEdGUI.Styles.ButtonRight, GUILayout.Width(30f))) { num3 = i; } EditorGUILayout.EndHorizontal(); GUI.enabled = true; } } if (num3 >= 1) { plyEdUtil.RemoveSceneFromBuildSettings(num3); } if (num4 >= 1) { plyTextInputWiz.ShowWiz("Rename Scene", "Enter unique name for scene", plyEdUtil.SceneNameFromPath(EditorBuildSettings.scenes[num4].path), this.OnRenameScene, new object[1] { num4 }, 250f); } if (num >= 1) { if (this.bootstrap.startupScenes.Contains(num)) { this.bootstrap.startupScenes.Remove(num); } else { this.bootstrap.startupScenes.Add(num); if (this.bootstrap.autoloadScenes.Contains(num)) { this.bootstrap.autoloadScenes.Remove(num); } } EditorUtility.SetDirty(this.bootstrap); } if (num2 >= 1) { if (this.bootstrap.autoloadScenes.Contains(num2)) { this.bootstrap.autoloadScenes.Remove(num2); } else { this.bootstrap.autoloadScenes.Add(num2); if (this.bootstrap.startupScenes.Contains(num2)) { this.bootstrap.startupScenes.Remove(num2); } } EditorUtility.SetDirty(this.bootstrap); } } }