public static void SetAuthoringProject(Project project) { var previous = AuthoringProject; AuthoringProject = project; if (null != previous) { EndAuthoringProject(previous); previous.Dispose(); } if (null != AuthoringProject) { EditorModes.SetDotsMode(); BeginAuthoringProject(AuthoringProject); project.Session.GetManager <IChangeManager>().Update(); project.Session.GetManager <IUndoManager>().Flush(); } else { EditorModes.SetDefaultMode(); } Bridge.EditorApplication.UpdateMainWindowTitle(); }
protected void RegisterSelectedPane(bool sendEvents) { if (!m_ActualView) { return; } m_ActualView.m_Parent = this; visualTree.Add(EditorModes.GetRootElement(m_ActualView)); panel.getViewDataDictionary = m_ActualView.GetViewDataDictionary; panel.savePersistentViewData = m_ActualView.SavePersistentViewData; panel.name = m_ActualView.GetType().Name; if (GetPaneMethod("Update") != null) { EditorApplication.update += SendUpdate; } EditorApplication.update += SendUpdateToOverride; if (GetPaneMethod("ModifierKeysChanged") != null) { EditorApplication.modifierKeysChanged += SendModKeysChanged; } EditorApplication.update += SendModKeysChangedToOverride; m_ActualView.MakeParentsSettingsMatchMe(); if (m_ActualView.m_FadeoutTime != 0) { EditorApplication.update += m_ActualView.CheckForWindowRepaint; } if (sendEvents) { try { Invoke("OnBecameVisible"); EditorModes.OnBecameVisible(m_ActualView); Invoke("OnFocus"); EditorModes.OnFocus(m_ActualView); } catch (TargetInvocationException ex) { // We need to catch these so the window initialization doesn't get screwed if (ex.InnerException != null) { Debug.LogError(ex.InnerException.GetType().Name + ":" + ex.InnerException.Message); } } } UpdateViewMargins(m_ActualView); }
public void PopupGenericMenu(EditorWindow view, Rect pos) { GenericMenu menu = new GenericMenu(); EditorModes.AddItemsToMenu(view, menu); AddDefaultItemsToMenu(menu, view); menu.DropDown(pos); Event.current.Use(); }
protected virtual void SetActualViewPosition(Rect newPos) { if (m_ActualView != null) { m_ActualView.m_Pos = newPos; UpdateViewMargins(m_ActualView); m_ActualView.OnResized(); EditorModes.OnResize(m_ActualView); } }
private void OnEditorModeRadioButtonChecked(object sender, RoutedEventArgs e) { if (!this.IsLoaded) { return; } _currentEditorMode = (CreateRadioButton.IsChecked ?? false) ? EditorModes.Create : EditorModes.Edit; _currentObjectCreationState = (_currentEditorMode == EditorModes.Create) ? ObjectCreationStates.SelectStartPoint : ObjectCreationStates.None; UpdateEditorModeUI(); }
protected void DeregisterSelectedPane(bool clearActualView, bool sendEvents) { if (!m_ActualView) { return; } var root = EditorModes.GetRootElement(m_ActualView); if (root.shadow.parent == visualTree) { visualTree.Remove(root); panel.getViewDataDictionary = null; panel.savePersistentViewData = null; } if (GetPaneMethod("Update") != null) { EditorApplication.update -= SendUpdate; } EditorApplication.update -= SendUpdateToOverride; if (GetPaneMethod("ModifierKeysChanged") != null) { EditorApplication.modifierKeysChanged -= SendModKeysChanged; } EditorApplication.update -= SendModKeysChangedToOverride; if (m_ActualView.m_FadeoutTime != 0) { EditorApplication.update -= m_ActualView.CheckForWindowRepaint; } if (clearActualView) { EditorWindow oldActualView = m_ActualView; m_ActualView = null; if (sendEvents) { Invoke("OnLostFocus", oldActualView); EditorModes.OnLostFocus(m_ActualView); Invoke("OnBecameInvisible", oldActualView); EditorModes.OnBecameInvisible(oldActualView); } } }
protected override void OldOnGUI() { ClearBackground(); // Call reset GUI state as first thing so GUI.color is correct when drawing window decoration. EditorGUIUtility.ResetGUIState(); DoWindowDecorationStart(); if (background == null) { background = "hostview"; // Fix annoying GUILayout issue: When using guilayout in Utility windows there was always padded 10 px at the top! Todo: Fix this in EditorResources background.padding.top = 0; } using (new GUILayout.VerticalScope(background)) { if (actualView) { actualView.m_Pos = screenPosition; } try { if (EditorModes.ShouldInvokeOnGUI(m_ActualView)) { Invoke("OnGUI"); } } finally { if (m_ActualView != null) { if (m_ActualView.m_FadeoutTime != 0 && Event.current.type == EventType.Repaint) { m_ActualView.DrawNotification(); } } DoWindowDecorationEnd(); EditorGUI.ShowRepaints(); } } }
protected override void UpdateViewMargins(EditorWindow view) { base.UpdateViewMargins(view); if (view == null) { return; } RectOffset margins = GetBorderSize(); IStyle style = EditorModes.GetRootElement(view).style; style.positionTop = margins.top; style.positionBottom = margins.bottom; style.positionLeft = margins.left; style.positionRight = margins.right; style.positionType = PositionType.Absolute; }
internal static void NewProject() { var defaultProjectSettings = ProjectSettings.Default; var path = EditorUtility.SaveFilePanelInProject(title: "New Project", defaultName: "NewProject", extension: string.Empty, message: "Select a new project directory"); if (string.IsNullOrEmpty(path)) { return; } if (Application.AuthoringProject != null) { Application.SetAuthoringProject(null); } var file = new FileInfo(path); Project.Create(file.Directory, file.Name); EditorModes.SetDotsMode(); }
public SceneEditor() { InitializeComponent(); _currentEditorMode = EditorModes.Create; var materialGroup = new MaterialGroup(); materialGroup.Children.Add(new DiffuseMaterial(new SolidColorBrush(Color.FromArgb(200, 36, 117, 137)))); // #247589 materialGroup.Children.Add(new SpecularMaterial(Brushes.White, 16)); materialGroup.Freeze(); _standardMaterial = materialGroup; _standardBackMaterial = new DiffuseMaterial(new SolidColorBrush(Color.FromRgb(36, 117, 137))); _standardBackMaterial.Freeze(); UpdateEditorModeUI(); SetupOverlayViewport3D(); // We need to synchronize the Lights in OverlayViewport with the camera in the MainViewport Camera1.CameraChanged += delegate(object s, CameraChangedRoutedEventArgs args) { // When camera is changed, we need to update the 2D positions that are get from 3D points OverlayCanvas.UpdateScreenPositions(); }; MainViewport.SizeChanged += delegate(object sender, SizeChangedEventArgs args) { // When MainViewport's size is changed, we need to update the 2D positions that are get from 3D points OverlayCanvas.UpdateScreenPositions(); }; this.Loaded += SceneEditor_Loaded; }
public bool TrySelectWindow(EditorWindow searchedWindow) { var root = EditorModes.GetRootElement(searchedWindow); if (root == null) { return(false); } IPanel searchedPanel = root.panel; for (int i = 0; i < m_Panels.Count; i++) { var p = m_Panels[i]; if (p.Panel == searchedPanel) { m_Selected = i + 1; return(true); } } return(false); }
/// <summary> /// /// </summary> private void GlobalInput() { //if (GameInput.IsKeyPressed(Keys.F6)) //{ // CompilerWindow cf = new CompilerWindow(); // cf.Show(); //} if (GameInput.IsKeyDown(Keys.LeftControl) && GameInput.IsKeyPressed(Keys.F9)) { lock (this) { if (EditorHandler.SelectedGameObjects != null && EditorHandler.SelectedGameObjects.Count > 0 && !takingScreenshot) { takingScreenshot = true; RotatedRectangle r = EditorHandler.SelectedGameObjects[0].MeasureDimension(); TakeScreenshot(r.Width, r.Height); takingScreenshot = false; } } } else if (GameInput.IsKeyPressed(Keys.F9) && !takingScreenshot) { lock (this) { takingScreenshot = true; TakeScreenshot(); takingScreenshot = false; } } if (TileSetMode) { if (GameInput.IsKeyDown(Keys.Escape)) { EditorHandler.SelectedGameObjects.Clear(); EditorHandler.ChangeSelectedObjects(); } } //if (GameInput.IsKeyPressed(Keys.F5)) // EditorCommands.DebugGame(); if (this.Focused) { if (GameInput.IsKeyPressed(Keys.Delete)) { if (EditorHandler.SelectedGameObjects.Count > 0 && MessageBox.Show("Are you sure you want to delete the selected game object(s)?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { foreach (GameObject gameObject in EditorHandler.SelectedGameObjects) { GameObject.Remove(gameObject); } EditorHandler.SceneTreeView.CreateView(); EditorHandler.SelectedGameObjects = new List<GameObject>(); EditorHandler.ChangeSelectedObjects(); } } else if (GameInput.IsKeyPressed(Keys.Q)) { editorMode = EditorModes.Select; } else if (GameInput.IsKeyPressed(Keys.E)) { editorMode = EditorModes.Move; } else if (GameInput.IsKeyPressed(Keys.R)) { editorMode = EditorModes.Rotate; } else if (GameInput.IsKeyPressed(Keys.T)) { editorMode = EditorModes.Scale; } else if (GameInput.IsKeyPressed(Keys.G)) { SceneManager.GameProject.EditorSettings.ShowGrid = !SceneManager.GameProject.EditorSettings.ShowGrid; } } }
public bool ValidFor(EditorModes mode) { return !ValidInMode.HasValue || ValidInMode.Value == mode; }
void SendModKeysChangedToOverride() { EditorModes.ModifierKeysChanged(m_ActualView); }
public void InvokeOnGUI(Rect onGUIPosition, Rect viewRect) { // Handle window reloading. if (Unsupported.IsDeveloperMode() && actualView != null && Event.current.type == EventType.KeyUp && Event.current.keyCode == KeyCode.F5) { if (Event.current.control) { DebugWindow(actualView); } else { Reload(actualView); } return; } DoWindowDecorationStart(); if (m_IsGameView) // GameView exits GUI, so draw overlay border earlier { GUI.Box(onGUIPosition, GUIContent.none, HostViewStyles.overlay); } BeginOffsetArea(viewRect, GUIContent.none, "TabWindowBackground"); EditorGUIUtility.ResetGUIState(); bool isExitGUIException = false; try { using (new PerformanceTracker(actualView.GetType().Name + ".OnGUI")) { if (EditorModes.ShouldInvokeOnGUI(m_ActualView)) { Invoke("OnGUI"); } } } catch (TargetInvocationException e) { if (e.InnerException is ExitGUIException) { isExitGUIException = true; } throw; } finally { // We can't reset gui state after ExitGUI we just want to bail completely if (!isExitGUIException) { bool isRepaint = (Event.current != null && Event.current.type == EventType.Repaint); if (actualView != null && actualView.m_FadeoutTime != 0 && isRepaint) { actualView.DrawNotification(); } EndOffsetArea(); EditorGUIUtility.ResetGUIState(); DoWindowDecorationEnd(); if (isRepaint) { HostViewStyles.overlay.Draw(onGUIPosition, GUIContent.none, 0); } } } }
/// <summary> /// Sets the currently viewed editor panel /// </summary> /// <param name="editMode">The edit panel to view</param> public void setEditorMode(EditorModes editMode) { // If we want the last used panel, see which panel is one level down and activate it if (editMode == EditorModes.LastMode && this.splitContainer2.Panel1.Controls.Count > 1) { switch (this.splitContainer2.Panel1.Controls[1].Name) { case "hexView1": editMode = EditorModes.HexViewer; break; case "LibraryPanel": editMode = EditorModes.PluginViewer; break; case "ltmpTools": editMode = EditorModes.BitmapViewer; break; case "MetaEditorPanel": editMode = EditorModes.MetaEditor1; break; case "MetaEditor2Panel": editMode = EditorModes.MetaEditor2; break; case "references": editMode = EditorModes.ReferenceEditor; break; default: return; } } // Only allow bitmaps to select Bitmap Viewer if (editMode == EditorModes.BitmapViewer && map.SelectedMeta.type != "bitm") { ltmpTools.Visible = true; return; } // "Check" the selected panel hexEditorToolStripMenuItem.Checked = (editMode == EditorModes.HexViewer); bitmapEditorToolStripMenuItem.Checked = (editMode == EditorModes.BitmapViewer); metaEditorToolStripMenuItem.Checked = (editMode == EditorModes.MetaEditor1); metaEditorNewToolStripMenuItem.Checked = (editMode == EditorModes.MetaEditor2); pluginsToolStripMenuItem.Checked = (editMode == EditorModes.PluginViewer); referenceEditorToolStripMenuItem.Checked = (editMode == EditorModes.ReferenceEditor); Control c = null; switch (editMode) { case EditorModes.BitmapViewer: c = ltmpTools; break; case EditorModes.HexViewer: c = hexView1; break; case EditorModes.MetaEditor1: c = MetaEditorPanel; break; case EditorModes.MetaEditor2: c = MetaEditor2Panel; break; case EditorModes.PluginViewer: c = LibraryPanel; break; case EditorModes.ReferenceEditor: c = references; break; } if (c != null) { c.Visible = true; if (c.Parent == splitContainer2.Panel1) { c.BringToFront(); // Hide all other panels, except for Bitmap Viewer for (int i = 1; i < this.splitContainer2.Panel1.Controls.Count; i++) { if (this.splitContainer2.Panel1.Controls[i] != ltmpTools) this.splitContainer2.Panel1.Controls[i].Visible = false; } // This method allows us to have an auto-bitmap viewer if (map.SelectedMeta != null && map.SelectedMeta.type == "bitm") if (editMode != EditorModes.BitmapViewer) ltmpTools.Visible = false; else this.splitContainer2.Panel1.Controls[1].Visible = true; //ltmpTools.SendToBack(); } } if (map.SelectedMeta != null) { LoadMeta(map.SelectedMeta.TagIndex); } }
internal void OnSelectionChange() { Invoke("OnSelectionChange"); EditorModes.OnSelectionChanged(m_ActualView); }
/// <summary> /// Updates the UI of this form /// </summary> public void UpdateUI() { if (SceneManager.GameProject != null) { string sceneName = (SceneManager.ActiveScene != null) ? sceneName = Path.GetFileNameWithoutExtension(SceneManager.ActiveScenePath) : ""; this.Text = string.Format("{0} - {1} - {2}", Properties.Resources.DisplayName, SceneManager.GameProject.ProjectName, sceneName); showGridBtn.Checked = SceneManager.GameProject.EditorSettings.ShowGrid; gridSnappingBtn.Checked = SceneManager.GameProject.EditorSettings.SnapToGrid; showCollisionsButton.Checked = SceneManager.GameProject.EditorSettings.ShowCollisions; // Console.WriteLine(sceneEditorControl1.EditorMode + ":" + lastEditorMode); if (sceneEditorControl1.EditorMode != lastEditorMode) { selectStripBtn.Checked = false; moveStripButton.Checked = false; scaleStripButton.Checked = false; rotateStripButton.Checked = false; if (sceneEditorControl1.EditorMode == EditorModes.Select) { selectStripBtn.Checked = true; } else if (sceneEditorControl1.EditorMode == EditorModes.Move) { moveStripButton.Checked = true; } else if (sceneEditorControl1.EditorMode == EditorModes.Rotate) { rotateStripButton.Checked = true; } else if (sceneEditorControl1.EditorMode == EditorModes.Scale) { scaleStripButton.Checked = true; } lastEditorMode = sceneEditorControl1.EditorMode; } //if (sceneEditorControl1.Camera.Zoom != lastZoom) //{ // lastZoom = sceneEditorControl1.Camera.Zoom; // float zoom = (float)Math.Round(sceneEditorControl1.Camera.Zoom * 10) * 10.0f; // zoomCombo.Text = zoom.ToString() + "%"; //} } }
public void InitUI(MainEditorForm inEditorForm) { EditorForm = inEditorForm; CurrentEditorMode = EditorModes.BaseReadOnly; //ReloadData(); }
void timerUI_Tick(object sender, EventArgs e) { if (SceneManager.GameProject != null) { string sceneName = (SceneManager.ActiveScene != null) ? sceneName = System.IO.Path.GetFileNameWithoutExtension(SceneManager.ActiveScenePath) : ""; this.Title = string.Format("{0} - {1} - {2}", "Gibbo 2D [" + versionInfo + "]", SceneManager.GameProject.ProjectName, sceneName); showGridBtn.IsChecked = SceneManager.GameProject.EditorSettings.ShowGrid; gridSnappingBtn.IsChecked = SceneManager.GameProject.EditorSettings.SnapToGrid; showCollisionsBtn.IsChecked = SceneManager.GameProject.EditorSettings.ShowCollisions; debugViewBtn.IsChecked = Properties.Settings.Default.ShowDebugView; // Console.WriteLine(sceneEditorControl1.EditorMode + ":" + lastEditorMode); if (sceneViewGameControl.EditorMode != lastEditorMode) { selectBtn.IsChecked = false; translateBtn.IsChecked = false; rotateBtn.IsChecked = false; scaleBtn.IsChecked = false; if (sceneViewGameControl.EditorMode == EditorModes.Select) { selectBtn.IsChecked = true; } else if (sceneViewGameControl.EditorMode == EditorModes.Move) { translateBtn.IsChecked = true; } else if (sceneViewGameControl.EditorMode == EditorModes.Rotate) { rotateBtn.IsChecked = true; } else if (sceneViewGameControl.EditorMode == EditorModes.Scale) { scaleBtn.IsChecked = true; } lastEditorMode = sceneViewGameControl.EditorMode; } } }
internal void OnInspectorUpdate() { Invoke("OnInspectorUpdate"); EditorModes.OnInspectorUpdate(m_ActualView); }
// Messages sent by Unity to editor windows today. // The implementation is not very good, but oh well... it gets the message across. internal void OnProjectChange() { Invoke("OnProjectChange"); EditorModes.OnProjectChange(m_ActualView); }
public CmdHelpAttribute(EditorModes forMode, string helpMessage) { this.HelpMessage = helpMessage; this.ValidInMode = forMode; }
internal void OnDidOpenScene() { Invoke("OnDidOpenScene"); EditorModes.OnDidOpenScene(m_ActualView); }
public bool ValidFor(EditorModes mode) { return(!ValidInMode.HasValue || ValidInMode.Value == mode); }
internal void OnHierarchyChange() { Invoke("OnHierarchyChange"); EditorModes.OnHierarchyChange(m_ActualView); }
/// <summary> /// /// </summary> private void GlobalInput() { if (GameInput.IsKeyPressed(Keys.F6)) { CompilerForm cf = new CompilerForm(); cf.Show(); } if (TileSetMode) { if (GameInput.IsKeyDown(Keys.Escape)) { EditorHandler.SelectedGameObjects.Clear(); EditorHandler.ChangeSelectedObjects(); } } if (GameInput.IsKeyPressed(Keys.F5)) EditorCommands.DebugGame(); if (GameInput.IsKeyDown(Keys.LeftControl) && GameInput.IsKeyPressed(Keys.S)) { EditorCommands.SaveProject(); EditorCommands.SaveScene(false); } if (this.Focused) { if (GameInput.IsKeyPressed(Keys.Delete)) { if (EditorHandler.SelectedGameObjects.Count > 0 && ComponentFactory.Krypton.Toolkit.KryptonMessageBox.Show("Are you sure you want to delete the selected game object(s)?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { foreach (GameObject gameObject in EditorHandler.SelectedGameObjects) { GameObject.Remove(gameObject); } EditorHandler.SceneTreeView.CreateView(); EditorHandler.SelectedGameObjects = new List<GameObject>(); EditorHandler.ChangeSelectedObjects(); } } else if (GameInput.IsKeyPressed(Keys.Q)) { editorMode = EditorModes.Select; } else if (GameInput.IsKeyPressed(Keys.E)) { editorMode = EditorModes.Move; } else if (GameInput.IsKeyPressed(Keys.R)) { editorMode = EditorModes.Rotate; } else if (GameInput.IsKeyPressed(Keys.T)) { editorMode = EditorModes.Scale; } else if (GameInput.IsKeyPressed(Keys.G)) { SceneManager.GameProject.EditorSettings.ShowGrid = !SceneManager.GameProject.EditorSettings.ShowGrid; } } }
void SendUpdateToOverride() { EditorModes.Update(m_ActualView); }
private void OnEnableINTERNAL() { EditorModes.RegisterWindow(this); }
private void OnDisableINTERNAL() { EditorModes.UnregisterWindow(this); }
internal static VisualElement GetRootVisualContainerForCurrentMode(this EditorWindow window) { return(EditorModes.GetRootElement(window)); }
internal void MenuChanged(EditorModes menu) { composeToolStripMenuItem.Checked = menu == EditorModes.Compose; designToolStripMenuItem.Checked = menu == EditorModes.Design; timingToolStripMenuItem.Checked = menu == EditorModes.Timing; }
public CmdHelpAttribute(EditorModes forMode, string helpMessage) { this.HelpMessage= helpMessage; this.ValidInMode = forMode; }