From 37c8aacd8b2d17ba1864ddadf77461e5ff370506 Mon Sep 17 00:00:00 2001 From: Ruan Lucas <79365912+RuanLucasGD@users.noreply.github.com> Date: Fri, 14 Oct 2022 15:20:57 -0400 Subject: [PATCH 01/29] Fix math node size --- Source/Editor/Surface/Archetypes/Math.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/Surface/Archetypes/Math.cs b/Source/Editor/Surface/Archetypes/Math.cs index 4518a3090..caedbdc2a 100644 --- a/Source/Editor/Surface/Archetypes/Math.cs +++ b/Source/Editor/Surface/Archetypes/Math.cs @@ -47,7 +47,7 @@ namespace FlaxEditor.Surface.Archetypes Description = desc, Flags = NodeFlags.AllGraphs, AlternativeTitles = altTitles, - Size = new Float2(110, 40), + Size = new Float2(140, 40), DefaultType = new ScriptType(inputType), ConnectionsHints = hints, IndependentBoxes = new[] { 0, 1 }, From 546501a553e3cb13c06bec56c0cb9654202656f8 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Sun, 16 Oct 2022 18:50:00 -0500 Subject: [PATCH 02/29] Added performing layout when deleting actors and scrolling to duplicated/ pasted actors when action is performed. --- Source/Editor/Modules/SceneEditingModule.cs | 10 ++++++++++ Source/Editor/Windows/SceneTreeWindow.cs | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/Source/Editor/Modules/SceneEditingModule.cs b/Source/Editor/Modules/SceneEditingModule.cs index 9ffbc514f..b04249214 100644 --- a/Source/Editor/Modules/SceneEditingModule.cs +++ b/Source/Editor/Modules/SceneEditingModule.cs @@ -450,7 +450,11 @@ namespace FlaxEditor.Modules SelectionDeleteEnd?.Invoke(); if (isSceneTreeFocus) + { Editor.Windows.SceneWin.Focus(); + Editor.Windows.SceneWin.PerformLayout(); + Editor.Windows.SceneWin.PerformLayout(); + } } /// @@ -514,6 +518,9 @@ namespace FlaxEditor.Modules Undo.AddAction(new MultiUndoAction(pasteAction, selectAction)); OnSelectionChanged(); } + + // Scroll to new selected node while pasting + Editor.Windows.SceneWin.ScrollToSelectedNode(); } /// @@ -611,6 +618,9 @@ namespace FlaxEditor.Modules Undo.AddAction(new MultiUndoAction(undoActions)); OnSelectionChanged(); } + + // Scroll to new selected node while duplicating + Editor.Windows.SceneWin.ScrollToSelectedNode(); } /// diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs index b0bed2002..6e5b1f46e 100644 --- a/Source/Editor/Windows/SceneTreeWindow.cs +++ b/Source/Editor/Windows/SceneTreeWindow.cs @@ -209,6 +209,17 @@ namespace FlaxEditor.Windows if (_sceneTreePanel.HScrollBar != null) _sceneTreePanel.HScrollBar.ThumbEnabled = enabled; } + + /// + /// Scroll to selected node in the scene tree + /// + public void ScrollToSelectedNode() + { + // Scroll to node + var nodeSelection = _tree.Selection; + var scrollPosition = nodeSelection[nodeSelection.Count - 1]; + _sceneTreePanel.ScrollViewTo(scrollPosition); + } private void OnSearchBoxTextChanged() { From ef34ad760006d49e9be0fa572f2929dfe6ac9fb8 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Sun, 16 Oct 2022 19:05:41 -0500 Subject: [PATCH 03/29] Renamed scrollPosition to scrollControl for more accurate description --- Source/Editor/Windows/SceneTreeWindow.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs index 6e5b1f46e..17a0b7807 100644 --- a/Source/Editor/Windows/SceneTreeWindow.cs +++ b/Source/Editor/Windows/SceneTreeWindow.cs @@ -217,8 +217,8 @@ namespace FlaxEditor.Windows { // Scroll to node var nodeSelection = _tree.Selection; - var scrollPosition = nodeSelection[nodeSelection.Count - 1]; - _sceneTreePanel.ScrollViewTo(scrollPosition); + var scrollControl = nodeSelection[nodeSelection.Count - 1]; + _sceneTreePanel.ScrollViewTo(scrollControl); } private void OnSearchBoxTextChanged() From 2c3007eb2b479ee2d776a5571a2bcec67594e4ef Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Mon, 17 Oct 2022 19:55:30 -0500 Subject: [PATCH 04/29] cache viewport snapping enabled --- Source/Editor/Viewport/MainEditorGizmoViewport.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index eb82a42bf..e4da6f26f 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -6,6 +6,7 @@ using FlaxEditor.Content; using FlaxEditor.Gizmo; using FlaxEditor.GUI.ContextMenu; using FlaxEditor.GUI.Drag; +using FlaxEditor.Options; using FlaxEditor.SceneGraph; using FlaxEditor.SceneGraph.Actors; using FlaxEditor.Scripting; @@ -223,6 +224,12 @@ namespace FlaxEditor.Viewport editor.SceneEditing.SelectionChanged += OnSelectionChanged; + // initialize snapping enabled from cached values + string cachedSnapState; + TransformGizmo.TranslationSnapEnable = _editor.ProjectCache.TryGetCustomData("TranslateSnapState", out cachedSnapState) && Boolean.Parse(cachedSnapState); + TransformGizmo.RotationSnapEnabled = _editor.ProjectCache.TryGetCustomData("RotationSnapState", out cachedSnapState) && Boolean.Parse(cachedSnapState); + TransformGizmo.ScaleSnapEnabled = _editor.ProjectCache.TryGetCustomData("ScaleSnapState", out cachedSnapState) && Boolean.Parse(cachedSnapState); + // Transform space widget var transformSpaceWidget = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperRight); var transformSpaceToggle = new ViewportWidgetButton(string.Empty, editor.Icons.Globe32, null, true) @@ -523,16 +530,22 @@ namespace FlaxEditor.Viewport private void OnTranslateSnappingToggle(ViewportWidgetButton button) { TransformGizmo.TranslationSnapEnable = !TransformGizmo.TranslationSnapEnable; + // cache value on next save + _editor.ProjectCache.SetCustomData("TranslateSnapState", TransformGizmo.TranslationSnapEnable.ToString()); } private void OnRotateSnappingToggle(ViewportWidgetButton button) { TransformGizmo.RotationSnapEnabled = !TransformGizmo.RotationSnapEnabled; + // cache value on next save + _editor.ProjectCache.SetCustomData("RotationSnapState", TransformGizmo.RotationSnapEnabled.ToString()); } private void OnScaleSnappingToggle(ViewportWidgetButton button) { TransformGizmo.ScaleSnapEnabled = !TransformGizmo.ScaleSnapEnabled; + // cache value on next save + _editor.ProjectCache.SetCustomData("ScaleSnapState", TransformGizmo.ScaleSnapEnabled.ToString()); } private void OnTransformSpaceToggle(ViewportWidgetButton button) From 212fc0838aa187fcf3a31504e7268c8fd257c40e Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Mon, 17 Oct 2022 19:57:40 -0500 Subject: [PATCH 05/29] remove not needed include --- Source/Editor/Viewport/MainEditorGizmoViewport.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index e4da6f26f..140908faa 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -6,7 +6,6 @@ using FlaxEditor.Content; using FlaxEditor.Gizmo; using FlaxEditor.GUI.ContextMenu; using FlaxEditor.GUI.Drag; -using FlaxEditor.Options; using FlaxEditor.SceneGraph; using FlaxEditor.SceneGraph.Actors; using FlaxEditor.Scripting; From 456934c737114434fa6b29c68e9a3b5ebc5ff11a Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Mon, 17 Oct 2022 21:18:46 -0500 Subject: [PATCH 06/29] Added caching and loading snapping values --- .../Editor/Viewport/MainEditorGizmoViewport.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index 140908faa..d85079a1f 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -229,6 +229,21 @@ namespace FlaxEditor.Viewport TransformGizmo.RotationSnapEnabled = _editor.ProjectCache.TryGetCustomData("RotationSnapState", out cachedSnapState) && Boolean.Parse(cachedSnapState); TransformGizmo.ScaleSnapEnabled = _editor.ProjectCache.TryGetCustomData("ScaleSnapState", out cachedSnapState) && Boolean.Parse(cachedSnapState); + // initialize snap value if there is one cached + string cachedSnapValue; + if (_editor.ProjectCache.TryGetCustomData("TranslateSnapValue", out cachedSnapValue)) + { + TransformGizmo.TranslationSnapValue = float.Parse(cachedSnapValue); + } + if (_editor.ProjectCache.TryGetCustomData("RotationSnapValue", out cachedSnapValue)) + { + TransformGizmo.RotationSnapValue = float.Parse(cachedSnapValue); + } + if (_editor.ProjectCache.TryGetCustomData("ScaleSnapValue", out cachedSnapValue)) + { + TransformGizmo.ScaleSnapValue = float.Parse(cachedSnapValue); + } + // Transform space widget var transformSpaceWidget = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperRight); var transformSpaceToggle = new ViewportWidgetButton(string.Empty, editor.Icons.Globe32, null, true) @@ -579,6 +594,7 @@ namespace FlaxEditor.Viewport var v = (float)button.Tag; TransformGizmo.ScaleSnapValue = v; _scaleSnapping.Text = v.ToString(); + _editor.ProjectCache.SetCustomData("ScaleSnapValue", TransformGizmo.ScaleSnapValue.ToString("N")); } private void OnWidgetScaleSnapShowHide(Control control) @@ -616,6 +632,7 @@ namespace FlaxEditor.Viewport var v = (float)button.Tag; TransformGizmo.RotationSnapValue = v; _rotateSnapping.Text = v.ToString(); + _editor.ProjectCache.SetCustomData("RotationSnapValue", TransformGizmo.RotationSnapValue.ToString("N")); } private void OnWidgetRotateSnapShowHide(Control control) @@ -652,6 +669,7 @@ namespace FlaxEditor.Viewport var v = (float)button.Tag; TransformGizmo.TranslationSnapValue = v; _translateSnapping.Text = v.ToString(); + _editor.ProjectCache.SetCustomData("TranslateSnapValue", TransformGizmo.TranslationSnapValue.ToString("N")); } private void OnWidgetTranslateSnapShowHide(Control control) From 6c470c1247d349757b919c6cbc7fbeb79e0d35dc Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Mon, 17 Oct 2022 21:29:58 -0500 Subject: [PATCH 07/29] added caching of transform space and loading --- Source/Editor/Viewport/MainEditorGizmoViewport.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index d85079a1f..0933a5fde 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -243,7 +243,16 @@ namespace FlaxEditor.Viewport { TransformGizmo.ScaleSnapValue = float.Parse(cachedSnapValue); } - + + // initialize transform space if one is cached + string cachedTransformSpace; + if (_editor.ProjectCache.TryGetCustomData("TransformSpaceState", out cachedTransformSpace)) + { + TransformGizmoBase.TransformSpace space; + Enum.TryParse(cachedTransformSpace, out space); + TransformGizmo.ActiveTransformSpace = space; + } + // Transform space widget var transformSpaceWidget = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperRight); var transformSpaceToggle = new ViewportWidgetButton(string.Empty, editor.Icons.Globe32, null, true) @@ -565,6 +574,7 @@ namespace FlaxEditor.Viewport private void OnTransformSpaceToggle(ViewportWidgetButton button) { TransformGizmo.ToggleTransformSpace(); + _editor.ProjectCache.SetCustomData("TransformSpaceState", TransformGizmo.ActiveTransformSpace.ToString()); } private void OnGizmoModeChanged() From 9f9cc0e1ecc7e5c5d1a2c65999216c73f5138b58 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 19 Oct 2022 07:22:09 -0500 Subject: [PATCH 08/29] cleaned up comments --- Source/Editor/Viewport/MainEditorGizmoViewport.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index 0933a5fde..da9bd585d 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -553,27 +553,28 @@ namespace FlaxEditor.Viewport private void OnTranslateSnappingToggle(ViewportWidgetButton button) { TransformGizmo.TranslationSnapEnable = !TransformGizmo.TranslationSnapEnable; - // cache value on next save + // cache value _editor.ProjectCache.SetCustomData("TranslateSnapState", TransformGizmo.TranslationSnapEnable.ToString()); } private void OnRotateSnappingToggle(ViewportWidgetButton button) { TransformGizmo.RotationSnapEnabled = !TransformGizmo.RotationSnapEnabled; - // cache value on next save + // cache value _editor.ProjectCache.SetCustomData("RotationSnapState", TransformGizmo.RotationSnapEnabled.ToString()); } private void OnScaleSnappingToggle(ViewportWidgetButton button) { TransformGizmo.ScaleSnapEnabled = !TransformGizmo.ScaleSnapEnabled; - // cache value on next save + // cache value _editor.ProjectCache.SetCustomData("ScaleSnapState", TransformGizmo.ScaleSnapEnabled.ToString()); } private void OnTransformSpaceToggle(ViewportWidgetButton button) { TransformGizmo.ToggleTransformSpace(); + // cache value _editor.ProjectCache.SetCustomData("TransformSpaceState", TransformGizmo.ActiveTransformSpace.ToString()); } @@ -604,6 +605,7 @@ namespace FlaxEditor.Viewport var v = (float)button.Tag; TransformGizmo.ScaleSnapValue = v; _scaleSnapping.Text = v.ToString(); + // cache value _editor.ProjectCache.SetCustomData("ScaleSnapValue", TransformGizmo.ScaleSnapValue.ToString("N")); } @@ -642,6 +644,7 @@ namespace FlaxEditor.Viewport var v = (float)button.Tag; TransformGizmo.RotationSnapValue = v; _rotateSnapping.Text = v.ToString(); + // cache value _editor.ProjectCache.SetCustomData("RotationSnapValue", TransformGizmo.RotationSnapValue.ToString("N")); } @@ -679,6 +682,7 @@ namespace FlaxEditor.Viewport var v = (float)button.Tag; TransformGizmo.TranslationSnapValue = v; _translateSnapping.Text = v.ToString(); + // cache value _editor.ProjectCache.SetCustomData("TranslateSnapValue", TransformGizmo.TranslationSnapValue.ToString("N")); } From 14a9c99496940630a31082409ba67a70b1ba24ba Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 19 Oct 2022 14:50:39 -0500 Subject: [PATCH 09/29] fixed small bug of scene window not resizing when something is deleted but window isnt focused --- Source/Editor/Modules/SceneEditingModule.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/Editor/Modules/SceneEditingModule.cs b/Source/Editor/Modules/SceneEditingModule.cs index b04249214..7b28367ff 100644 --- a/Source/Editor/Modules/SceneEditingModule.cs +++ b/Source/Editor/Modules/SceneEditingModule.cs @@ -452,9 +452,11 @@ namespace FlaxEditor.Modules if (isSceneTreeFocus) { Editor.Windows.SceneWin.Focus(); - Editor.Windows.SceneWin.PerformLayout(); - Editor.Windows.SceneWin.PerformLayout(); } + + // fix scene window layout + Editor.Windows.SceneWin.PerformLayout(); + Editor.Windows.SceneWin.PerformLayout(); } /// From 13150ea553ea67752224426a730cc94f8c98a984 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 19 Oct 2022 15:25:42 -0500 Subject: [PATCH 10/29] changed snap enable to still use default values if cache data doesnt exist --- Source/Editor/Viewport/MainEditorGizmoViewport.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index da9bd585d..80393302b 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -225,9 +225,18 @@ namespace FlaxEditor.Viewport // initialize snapping enabled from cached values string cachedSnapState; - TransformGizmo.TranslationSnapEnable = _editor.ProjectCache.TryGetCustomData("TranslateSnapState", out cachedSnapState) && Boolean.Parse(cachedSnapState); - TransformGizmo.RotationSnapEnabled = _editor.ProjectCache.TryGetCustomData("RotationSnapState", out cachedSnapState) && Boolean.Parse(cachedSnapState); - TransformGizmo.ScaleSnapEnabled = _editor.ProjectCache.TryGetCustomData("ScaleSnapState", out cachedSnapState) && Boolean.Parse(cachedSnapState); + if (_editor.ProjectCache.TryGetCustomData("TranslateSnapState", out cachedSnapState)) + { + TransformGizmo.TranslationSnapEnable = Boolean.Parse(cachedSnapState); + } + if (_editor.ProjectCache.TryGetCustomData("RotationSnapState", out cachedSnapState)) + { + TransformGizmo.RotationSnapEnabled = Boolean.Parse(cachedSnapState); + } + if (_editor.ProjectCache.TryGetCustomData("ScaleSnapState", out cachedSnapState)) + { + TransformGizmo.ScaleSnapEnabled = Boolean.Parse(cachedSnapState); + } // initialize snap value if there is one cached string cachedSnapValue; From dbcaf28f39e7b8808e641996428a7825a986ea2d Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 19 Oct 2022 15:28:59 -0500 Subject: [PATCH 11/29] added if check on enum parse --- Source/Editor/Viewport/MainEditorGizmoViewport.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index 80393302b..93ac05373 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -257,9 +257,10 @@ namespace FlaxEditor.Viewport string cachedTransformSpace; if (_editor.ProjectCache.TryGetCustomData("TransformSpaceState", out cachedTransformSpace)) { - TransformGizmoBase.TransformSpace space; - Enum.TryParse(cachedTransformSpace, out space); - TransformGizmo.ActiveTransformSpace = space; + if (Enum.TryParse(cachedTransformSpace, out TransformGizmoBase.TransformSpace space)) + { + TransformGizmo.ActiveTransformSpace = space; + } } // Transform space widget From dd20da89d7f75c21a86abb14093396b940c0bd98 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 19 Oct 2022 19:45:07 -0500 Subject: [PATCH 12/29] added cursor change for changing of the property splitter --- .../CustomEditors/GUI/PropertiesList.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Source/Editor/CustomEditors/GUI/PropertiesList.cs b/Source/Editor/CustomEditors/GUI/PropertiesList.cs index 68c503c1b..9ff1f2533 100644 --- a/Source/Editor/CustomEditors/GUI/PropertiesList.cs +++ b/Source/Editor/CustomEditors/GUI/PropertiesList.cs @@ -31,6 +31,7 @@ namespace FlaxEditor.CustomEditors.GUI private float _splitterValue; private Rectangle _splitterRect; private bool _splitterClicked, _mouseOverSplitter; + private bool _cursorChanged; /// /// Gets or sets the splitter value (always in range [0; 1]). @@ -124,6 +125,18 @@ namespace FlaxEditor.CustomEditors.GUI if (_splitterClicked) { SplitterValue = location.X / Width; + Cursor = CursorType.SizeWE; + _cursorChanged = true; + } + else if (_mouseOverSplitter) + { + Cursor = CursorType.SizeWE; + _cursorChanged = true; + } + else if (_cursorChanged) + { + Cursor = CursorType.Default; + _cursorChanged = false; } base.OnMouseMove(location); @@ -162,6 +175,12 @@ namespace FlaxEditor.CustomEditors.GUI { // Clear flag _mouseOverSplitter = false; + + if (_cursorChanged) + { + Cursor = CursorType.Default; + _cursorChanged = false; + } base.OnMouseLeave(); } From 5d8403be5bf7848dbd764c278397bcf2fa4bfd5a Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 19 Oct 2022 20:59:55 -0500 Subject: [PATCH 13/29] moved UpdateCameraPreview call to on selection changed and on state change --- Source/Editor/Windows/EditGameWindow.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Source/Editor/Windows/EditGameWindow.cs b/Source/Editor/Windows/EditGameWindow.cs index 737b13728..6103129c1 100644 --- a/Source/Editor/Windows/EditGameWindow.cs +++ b/Source/Editor/Windows/EditGameWindow.cs @@ -150,8 +150,22 @@ namespace FlaxEditor.Windows }; Viewport.Task.ViewFlags = ViewFlags.DefaultEditor; + Editor.SceneEditing.SelectionChanged += OnSelectionChanged; + Editor.Scene.ActorRemoved += SceneOnActorRemoved; } + + /// + public override void OnEditorStateChanged() + { + base.OnEditorStateChanged(); + UpdateCameraPreview(); + } + + private void OnSelectionChanged() + { + UpdateCameraPreview(); + } /// /// Gets a value indicating whether actor pilot feature is active and in use. @@ -376,9 +390,6 @@ namespace FlaxEditor.Windows /// public override void Update(float deltaTime) { - // TODO: call camera preview update only on selection change, or state change - UpdateCameraPreview(); - if (Root.GetKeyDown(KeyboardKeys.F12)) { Viewport.TakeScreenshot(); From 78bd7713a9fe98dad30d665fc1ffce2012b36a91 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Wed, 19 Oct 2022 21:41:58 -0500 Subject: [PATCH 14/29] value boxes now hide your slide and return your mouse to the original position. --- Source/Editor/GUI/Input/ValueBox.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/Editor/GUI/Input/ValueBox.cs b/Source/Editor/GUI/Input/ValueBox.cs index 50cdd529c..1e9553d22 100644 --- a/Source/Editor/GUI/Input/ValueBox.cs +++ b/Source/Editor/GUI/Input/ValueBox.cs @@ -57,6 +57,7 @@ namespace FlaxEditor.GUI.Input private Float2 _startSlideLocation; private double _clickStartTime = -1; private bool _cursorChanged; + private Float2 _mouseClickedPosition; /// /// Occurs when value gets changed. @@ -244,8 +245,12 @@ namespace FlaxEditor.GUI.Input _startSlideLocation = location; _startSlideValue = _value; StartMouseCapture(true); - Cursor = CursorType.SizeWE; + + // Hide cursor and cache location + Cursor = CursorType.Hidden; + _mouseClickedPosition = location; _cursorChanged = true; + SlidingStart?.Invoke(); return true; } @@ -268,7 +273,7 @@ namespace FlaxEditor.GUI.Input } // Update cursor type so user knows they can slide value - if (CanUseSliding && SlideRect.Contains(location)) + if (CanUseSliding && SlideRect.Contains(location) && !_isSliding) { Cursor = CursorType.SizeWE; _cursorChanged = true; @@ -287,7 +292,8 @@ namespace FlaxEditor.GUI.Input { if (button == MouseButton.Left && _isSliding) { - // End sliding + // End sliding and return mouse to original location + Root.MousePosition = ScreenPos + _mouseClickedPosition; EndSliding(); return true; } From a65e812b45b98523519723ce6f1c9c633f75460b Mon Sep 17 00:00:00 2001 From: Ruan Lucas <79365912+RuanLucasGD@users.noreply.github.com> Date: Thu, 20 Oct 2022 19:57:23 -0400 Subject: [PATCH 15/29] Add method that returns a list of standard monitor resolutions --- Source/Engine/Engine/Screen.cpp | 98 +++++++++++++++++++++++++++++++++ Source/Engine/Engine/Screen.h | 7 +++ 2 files changed, 105 insertions(+) diff --git a/Source/Engine/Engine/Screen.cpp b/Source/Engine/Engine/Screen.cpp index b6cec67c6..1a424009d 100644 --- a/Source/Engine/Engine/Screen.cpp +++ b/Source/Engine/Engine/Screen.cpp @@ -66,6 +66,104 @@ void Screen::SetSize(const Float2& value) Size = value; } +Array Screen::GetAllResolutions() { + + // reference: https://en.wikipedia.org/wiki/List_of_common_resolutions + + // all list of monitors and video resolutions + Float2 rawResolutions[66] = { + Float2(480, 480), + Float2(528, 480), + Float2(544, 576), + Float2(544, 480), + Float2(640, 480), + Float2(704, 480), + Float2(704, 576), + Float2(720, 480), + Float2(720, 486), + Float2(720, 576), + Float2(768, 480), + Float2(800, 480), + Float2(800, 600), + Float2(960, 720), + Float2(1024, 600), + Float2(1024, 768), + Float2(1024, 1024), + Float2(1280, 720), + Float2(1280, 800), + Float2(1280, 1024), + Float2(1280, 1080), + Float2(1366, 768), + Float2(1440, 900), + Float2(1440, 1024), + Float2(1440, 1080), + Float2(1600, 900), + Float2(1600, 1024), + Float2(1600, 1200), + Float2(1680, 1050), + Float2(1828, 1332), + Float2(1920, 1080), + Float2(1920, 1400), + Float2(1920, 1440), + Float2(1990, 1080), + Float2(2048, 858), + Float2(2048, 1080), + Float2(2048, 1280), + Float2(2048, 1440), + Float2(2048, 1536), + Float2(2304, 1728), + Float2(2400, 1080), + Float2(2560, 1080), + Float2(2560, 1440), + Float2(2560, 1600), + Float2(2800, 2100), + Float2(3840, 2160), + Float2(2048, 1556), + Float2(3000, 2000), + Float2(3240, 2160), + Float2(3840, 2160), + Float2(4096, 1714), + Float2(4096, 2304), + Float2(5120, 2160), + Float2(5120, 2880), + Float2(5120, 1440), + Float2(5120, 3200), + Float2(6012, 3384), + Float2(7200, 3600), + Float2(7680, 4320), + Float2(7680, 4320), + Float2(8192, 4320), + Float2(10240, 4320), + Float2(15360, 8640) + }; + + Float2 primaryResolution = Platform::GetDesktopSize(); + Array resolutions = Array(); + + // invert horizontal resolutions to vertical + if (primaryResolution.Y > primaryResolution.X) + { + for (int i = 0; i < rawResolutions->Length(); i++) + { + rawResolutions[i] = Float2(rawResolutions[i].Y, rawResolutions[i].Y); + } + } + + for each (Float2 r in rawResolutions) + { + if (r.X >= primaryResolution.X && r.Y >= primaryResolution.Y) + { + break; + } + + resolutions.Add(r); + } + + resolutions.Add(primaryResolution); + + return resolutions; +} + Float2 Screen::ScreenToGameViewport(const Float2& screenPos) { #if USE_EDITOR diff --git a/Source/Engine/Engine/Screen.h b/Source/Engine/Engine/Screen.h index 7f0f4ff6d..8c349aef2 100644 --- a/Source/Engine/Engine/Screen.h +++ b/Source/Engine/Engine/Screen.h @@ -5,6 +5,7 @@ #include "Engine/Scripting/ScriptingType.h" #include "Engine/Input/Enums.h" #include "Engine/Core/Math/Vector2.h" +#include "Engine/Core/Collections/Array.h" /// /// Helper class to access display information. @@ -34,6 +35,12 @@ DECLARE_SCRIPTING_TYPE_NO_SPAWN(Screen); /// The value API_PROPERTY() static Float2 GetSize(); + /// + /// returns a list of standard resolutions used in monitors and media + /// + /// List of resolutions + API_PROPERTY() static Array GetAllResolutions(); + /// /// Converts the screen-space position to the game viewport position. /// From a4333dfcb6dc8c72f5f1454a511a937391fafdbe Mon Sep 17 00:00:00 2001 From: Ruan Lucas <79365912+RuanLucasGD@users.noreply.github.com> Date: Thu, 20 Oct 2022 20:26:08 -0400 Subject: [PATCH 16/29] add flag to work for desktop and linux only --- Source/Engine/Engine/Screen.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Engine/Engine/Screen.cpp b/Source/Engine/Engine/Screen.cpp index 1a424009d..462110100 100644 --- a/Source/Engine/Engine/Screen.cpp +++ b/Source/Engine/Engine/Screen.cpp @@ -69,7 +69,7 @@ void Screen::SetSize(const Float2& value) Array Screen::GetAllResolutions() { // reference: https://en.wikipedia.org/wiki/List_of_common_resolutions - +#if PLATFORM_DESKTOP || PLATFORM_LINUX // all list of monitors and video resolutions Float2 rawResolutions[66] = { Float2(480, 480), @@ -141,7 +141,7 @@ Array Screen::GetAllResolutions() { Array resolutions = Array(); // invert horizontal resolutions to vertical - if (primaryResolution.Y > primaryResolution.X) + if (primaryResolution.Y > primaryResolution.X) { for (int i = 0; i < rawResolutions->Length(); i++) { @@ -160,8 +160,10 @@ Array Screen::GetAllResolutions() { } resolutions.Add(primaryResolution); - return resolutions; +#else + return Array({ primaryResolution }); +#endif } Float2 Screen::ScreenToGameViewport(const Float2& screenPos) From e1dc5a2e81ac7911a48bc46b836eaf5580fb381a Mon Sep 17 00:00:00 2001 From: Ruan Lucas <79365912+RuanLucasGD@users.noreply.github.com> Date: Thu, 20 Oct 2022 20:47:02 -0400 Subject: [PATCH 17/29] remove incorrect method --- Source/Engine/Engine/Screen.cpp | 100 -------------------------------- Source/Engine/Engine/Screen.h | 6 -- 2 files changed, 106 deletions(-) diff --git a/Source/Engine/Engine/Screen.cpp b/Source/Engine/Engine/Screen.cpp index 462110100..b6cec67c6 100644 --- a/Source/Engine/Engine/Screen.cpp +++ b/Source/Engine/Engine/Screen.cpp @@ -66,106 +66,6 @@ void Screen::SetSize(const Float2& value) Size = value; } -Array Screen::GetAllResolutions() { - - // reference: https://en.wikipedia.org/wiki/List_of_common_resolutions -#if PLATFORM_DESKTOP || PLATFORM_LINUX - // all list of monitors and video resolutions - Float2 rawResolutions[66] = { - Float2(480, 480), - Float2(528, 480), - Float2(544, 576), - Float2(544, 480), - Float2(640, 480), - Float2(704, 480), - Float2(704, 576), - Float2(720, 480), - Float2(720, 486), - Float2(720, 576), - Float2(768, 480), - Float2(800, 480), - Float2(800, 600), - Float2(960, 720), - Float2(1024, 600), - Float2(1024, 768), - Float2(1024, 1024), - Float2(1280, 720), - Float2(1280, 800), - Float2(1280, 1024), - Float2(1280, 1080), - Float2(1366, 768), - Float2(1440, 900), - Float2(1440, 1024), - Float2(1440, 1080), - Float2(1600, 900), - Float2(1600, 1024), - Float2(1600, 1200), - Float2(1680, 1050), - Float2(1828, 1332), - Float2(1920, 1080), - Float2(1920, 1400), - Float2(1920, 1440), - Float2(1990, 1080), - Float2(2048, 858), - Float2(2048, 1080), - Float2(2048, 1280), - Float2(2048, 1440), - Float2(2048, 1536), - Float2(2304, 1728), - Float2(2400, 1080), - Float2(2560, 1080), - Float2(2560, 1440), - Float2(2560, 1600), - Float2(2800, 2100), - Float2(3840, 2160), - Float2(2048, 1556), - Float2(3000, 2000), - Float2(3240, 2160), - Float2(3840, 2160), - Float2(4096, 1714), - Float2(4096, 2304), - Float2(5120, 2160), - Float2(5120, 2880), - Float2(5120, 1440), - Float2(5120, 3200), - Float2(6012, 3384), - Float2(7200, 3600), - Float2(7680, 4320), - Float2(7680, 4320), - Float2(8192, 4320), - Float2(10240, 4320), - Float2(15360, 8640) - }; - - Float2 primaryResolution = Platform::GetDesktopSize(); - Array resolutions = Array(); - - // invert horizontal resolutions to vertical - if (primaryResolution.Y > primaryResolution.X) - { - for (int i = 0; i < rawResolutions->Length(); i++) - { - rawResolutions[i] = Float2(rawResolutions[i].Y, rawResolutions[i].Y); - } - } - - for each (Float2 r in rawResolutions) - { - if (r.X >= primaryResolution.X && r.Y >= primaryResolution.Y) - { - break; - } - - resolutions.Add(r); - } - - resolutions.Add(primaryResolution); - return resolutions; -#else - return Array({ primaryResolution }); -#endif -} - Float2 Screen::ScreenToGameViewport(const Float2& screenPos) { #if USE_EDITOR diff --git a/Source/Engine/Engine/Screen.h b/Source/Engine/Engine/Screen.h index 8c349aef2..e9dbe9279 100644 --- a/Source/Engine/Engine/Screen.h +++ b/Source/Engine/Engine/Screen.h @@ -35,12 +35,6 @@ DECLARE_SCRIPTING_TYPE_NO_SPAWN(Screen); /// The value API_PROPERTY() static Float2 GetSize(); - /// - /// returns a list of standard resolutions used in monitors and media - /// - /// List of resolutions - API_PROPERTY() static Array GetAllResolutions(); - /// /// Converts the screen-space position to the game viewport position. /// From b20967559b0192ba4a36d274a271941829fca918 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 20 Oct 2022 19:49:36 -0500 Subject: [PATCH 18/29] added to not close the child context menu on click --- Source/Editor/GUI/ContextMenu/ContextMenuChildMenu.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Editor/GUI/ContextMenu/ContextMenuChildMenu.cs b/Source/Editor/GUI/ContextMenu/ContextMenuChildMenu.cs index 13451fc02..4fef7313b 100644 --- a/Source/Editor/GUI/ContextMenu/ContextMenuChildMenu.cs +++ b/Source/Editor/GUI/ContextMenu/ContextMenuChildMenu.cs @@ -26,6 +26,7 @@ namespace FlaxEditor.GUI.ContextMenu : base(parent, text) { Text = text; + CloseMenuOnClick = false; } /// From ca49454615b1bb1f9a9c6e6a32aa3b30027cda1a Mon Sep 17 00:00:00 2001 From: Ruan Lucas <79365912+RuanLucasGD@users.noreply.github.com> Date: Thu, 20 Oct 2022 20:49:37 -0400 Subject: [PATCH 19/29] remove unused include --- Source/Engine/Engine/Screen.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Engine/Engine/Screen.h b/Source/Engine/Engine/Screen.h index e9dbe9279..7f0f4ff6d 100644 --- a/Source/Engine/Engine/Screen.h +++ b/Source/Engine/Engine/Screen.h @@ -5,7 +5,6 @@ #include "Engine/Scripting/ScriptingType.h" #include "Engine/Input/Enums.h" #include "Engine/Core/Math/Vector2.h" -#include "Engine/Core/Collections/Array.h" /// /// Helper class to access display information. From 0765b82a39998ddd55ffa104b32bc44f9935ea73 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 21 Oct 2022 09:54:16 -0500 Subject: [PATCH 20/29] changed the default for script memebers order. --- Source/Editor/Options/GeneralOptions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Editor/Options/GeneralOptions.cs b/Source/Editor/Options/GeneralOptions.cs index c3f38f34b..5f05cae2c 100644 --- a/Source/Editor/Options/GeneralOptions.cs +++ b/Source/Editor/Options/GeneralOptions.cs @@ -137,9 +137,9 @@ namespace FlaxEditor.Options /// /// Gets or sets an order of script properties/fields in properties panel. /// - [DefaultValue(MembersOrder.Alphabetical)] + [DefaultValue(MembersOrder.Declaration)] [EditorDisplay("Scripting", "Script Members Order"), EditorOrder(503), Tooltip("Order of script properties/fields in properties panel")] - public MembersOrder ScriptMembersOrder { get; set; } = MembersOrder.Alphabetical; + public MembersOrder ScriptMembersOrder { get; set; } = MembersOrder.Declaration; /// /// Gets or sets a value indicating whether automatically save the Visual Script asset editors when starting the play mode in editor. From 1c44c42b522cdf6deaad1ee181e1fc0b20280953 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 21 Oct 2022 14:14:13 -0500 Subject: [PATCH 21/29] fixed position of child CMs when having to open left --- Source/Editor/GUI/ContextMenu/ContextMenuBase.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs b/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs index 2edff5c92..400bf56cb 100644 --- a/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs +++ b/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs @@ -155,11 +155,19 @@ namespace FlaxEditor.GUI.ContextMenu if (parent is ContextMenu menu && menu._childCM != null) locationSS.Y += 30.0f * dpiScale; } - if (monitorBounds.Right < rightBottomLocationSS.X) + if (monitorBounds.Right < rightBottomLocationSS.X || _parentCM?.Direction == ContextMenuDirection.LeftDown || _parentCM?.Direction == ContextMenuDirection.LeftUp) { // Direction: left isLeft = true; - locationSS.X -= dpiSize.X; + + if (IsSubMenu && _parentCM != null) + { + locationSS.X -= _parentCM.Width + dpiSize.X; + } + else + { + locationSS.X -= dpiSize.X; + } } } From 9bd13c8ed5991a8efb26f6389b0393927f0b0bb1 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Fri, 21 Oct 2022 20:31:19 -0500 Subject: [PATCH 22/29] This adds more spacing between the content items in the content view and allows for resizing better than before. --- Source/Editor/Content/GUI/ContentView.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Source/Editor/Content/GUI/ContentView.cs b/Source/Editor/Content/GUI/ContentView.cs index bf9fb1715..6825910bc 100644 --- a/Source/Editor/Content/GUI/ContentView.cs +++ b/Source/Editor/Content/GUI/ContentView.cs @@ -716,19 +716,24 @@ namespace FlaxEditor.Content.GUI case ContentViewType.Tiles: { float defaultItemsWidth = ContentItem.DefaultWidth * viewScale; - int itemsToFit = Mathf.FloorToInt(width / defaultItemsWidth); + int itemsToFit = Mathf.FloorToInt(width / defaultItemsWidth) - 1; + if (itemsToFit < 1) + { + itemsToFit = 1; + } float itemsWidth = width / Mathf.Max(itemsToFit, 1); float itemsHeight = itemsWidth / defaultItemsWidth * (ContentItem.DefaultHeight * viewScale); + x = itemsToFit == 1 ? 0 : itemsWidth / itemsToFit; for (int i = 0; i < _children.Count; i++) { var c = _children[i]; c.Bounds = new Rectangle(x, y, itemsWidth, itemsHeight); - x += itemsWidth; + x += itemsWidth + itemsWidth / itemsToFit; if (x + itemsWidth > width) { - x = 0; - y += itemsHeight + 1; + x = itemsToFit == 1 ? 0 : itemsWidth / itemsToFit; + y += itemsHeight + 5; } } if (x > 0) @@ -743,7 +748,7 @@ namespace FlaxEditor.Content.GUI { var c = _children[i]; c.Bounds = new Rectangle(x, y, width, itemsHeight); - y += itemsHeight + 1; + y += itemsHeight + 5; } y += 40.0f; From c6523ed9cdd582d736aad1c6ffa45a8082e79288 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 23 Oct 2022 14:18:55 +0200 Subject: [PATCH 23/29] Fix crash when presenting task which swap chain is not ready --- Source/Engine/Graphics/GPUDevice.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Engine/Graphics/GPUDevice.cpp b/Source/Engine/Graphics/GPUDevice.cpp index 6a77fe858..b9f1aeba2 100644 --- a/Source/Engine/Graphics/GPUDevice.cpp +++ b/Source/Engine/Graphics/GPUDevice.cpp @@ -3,6 +3,7 @@ #include "GPUDevice.h" #include "RenderTargetPool.h" #include "GPUPipelineState.h" +#include "GPUSwapChain.h" #include "RenderTask.h" #include "RenderTools.h" #include "Graphics.h" @@ -12,7 +13,6 @@ #include "Engine/Content/Assets/Material.h" #include "Engine/Content/Content.h" #include "Engine/Content/SoftAssetReference.h" -#include "Engine/Platform/Windows/WindowsWindow.h" #include "Engine/Render2D/Render2D.h" #include "Engine/Engine/CommandLine.h" #include "Engine/Engine/Engine.h" @@ -408,7 +408,7 @@ void GPUDevice::DrawEnd() for (int32 i = RenderTask::Tasks.Count() - 1; i >= 0; i--) { const auto task = RenderTask::Tasks[i]; - if (task && task->LastUsedFrame == Engine::FrameCount && task->SwapChain) + if (task && task->LastUsedFrame == Engine::FrameCount && task->SwapChain && task->SwapChain->IsReady()) { lastWindowIndex = i; break; @@ -421,7 +421,7 @@ void GPUDevice::DrawEnd() for (int32 i = 0; i < RenderTask::Tasks.Count(); i++) { const auto task = RenderTask::Tasks[i]; - if (task && task->LastUsedFrame == Engine::FrameCount && task->SwapChain) + if (task && task->LastUsedFrame == Engine::FrameCount && task->SwapChain && task->SwapChain->IsReady()) { bool vsync = useVSync; if (lastWindowIndex != i) From 70c53a4f67e4470472a488e655b62e3c002b9bde Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 23 Oct 2022 14:19:17 +0200 Subject: [PATCH 24/29] Fix error if nothing is selected --- Source/Editor/Windows/SceneTreeWindow.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs index 17a0b7807..396bd3747 100644 --- a/Source/Editor/Windows/SceneTreeWindow.cs +++ b/Source/Editor/Windows/SceneTreeWindow.cs @@ -209,16 +209,19 @@ namespace FlaxEditor.Windows if (_sceneTreePanel.HScrollBar != null) _sceneTreePanel.HScrollBar.ThumbEnabled = enabled; } - + /// - /// Scroll to selected node in the scene tree + /// Scrolls to the selected node in the scene tree. /// public void ScrollToSelectedNode() { - // Scroll to node + // Scroll to node var nodeSelection = _tree.Selection; - var scrollControl = nodeSelection[nodeSelection.Count - 1]; - _sceneTreePanel.ScrollViewTo(scrollControl); + if (nodeSelection.Count != 0) + { + var scrollControl = nodeSelection[nodeSelection.Count - 1]; + _sceneTreePanel.ScrollViewTo(scrollControl); + } } private void OnSearchBoxTextChanged() From d89e31d155d320d639326cb316b252fe9b0ce28d Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 23 Oct 2022 14:26:06 +0200 Subject: [PATCH 25/29] Code style fix #777 --- .../Viewport/MainEditorGizmoViewport.cs | 54 ++++++------------- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index 93ac05373..a375bdd60 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -223,45 +223,21 @@ namespace FlaxEditor.Viewport editor.SceneEditing.SelectionChanged += OnSelectionChanged; - // initialize snapping enabled from cached values - string cachedSnapState; - if (_editor.ProjectCache.TryGetCustomData("TranslateSnapState", out cachedSnapState)) - { - TransformGizmo.TranslationSnapEnable = Boolean.Parse(cachedSnapState); - } - if (_editor.ProjectCache.TryGetCustomData("RotationSnapState", out cachedSnapState)) - { - TransformGizmo.RotationSnapEnabled = Boolean.Parse(cachedSnapState); - } - if (_editor.ProjectCache.TryGetCustomData("ScaleSnapState", out cachedSnapState)) - { - TransformGizmo.ScaleSnapEnabled = Boolean.Parse(cachedSnapState); - } - - // initialize snap value if there is one cached - string cachedSnapValue; - if (_editor.ProjectCache.TryGetCustomData("TranslateSnapValue", out cachedSnapValue)) - { - TransformGizmo.TranslationSnapValue = float.Parse(cachedSnapValue); - } - if (_editor.ProjectCache.TryGetCustomData("RotationSnapValue", out cachedSnapValue)) - { - TransformGizmo.RotationSnapValue = float.Parse(cachedSnapValue); - } - if (_editor.ProjectCache.TryGetCustomData("ScaleSnapValue", out cachedSnapValue)) - { - TransformGizmo.ScaleSnapValue = float.Parse(cachedSnapValue); - } - - // initialize transform space if one is cached - string cachedTransformSpace; - if (_editor.ProjectCache.TryGetCustomData("TransformSpaceState", out cachedTransformSpace)) - { - if (Enum.TryParse(cachedTransformSpace, out TransformGizmoBase.TransformSpace space)) - { - TransformGizmo.ActiveTransformSpace = space; - } - } + // Initialize snapping enabled from cached values + if (_editor.ProjectCache.TryGetCustomData("TranslateSnapState", out var cachedState)) + TransformGizmo.TranslationSnapEnable = bool.Parse(cachedState); + if (_editor.ProjectCache.TryGetCustomData("RotationSnapState", out cachedState)) + TransformGizmo.RotationSnapEnabled = bool.Parse(cachedState); + if (_editor.ProjectCache.TryGetCustomData("ScaleSnapState", out cachedState)) + TransformGizmo.ScaleSnapEnabled = bool.Parse(cachedState); + if (_editor.ProjectCache.TryGetCustomData("TranslateSnapValue", out cachedState)) + TransformGizmo.TranslationSnapValue = float.Parse(cachedState); + if (_editor.ProjectCache.TryGetCustomData("RotationSnapValue", out cachedState)) + TransformGizmo.RotationSnapValue = float.Parse(cachedState); + if (_editor.ProjectCache.TryGetCustomData("ScaleSnapValue", out cachedState)) + TransformGizmo.ScaleSnapValue = float.Parse(cachedState); + if (_editor.ProjectCache.TryGetCustomData("TransformSpaceState", out cachedState) && Enum.TryParse(cachedState, out TransformGizmoBase.TransformSpace space)) + TransformGizmo.ActiveTransformSpace = space; // Transform space widget var transformSpaceWidget = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperRight); From 5341e355ce731e7abc74fe2792361101c4d8f92d Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 23 Oct 2022 20:14:58 +0200 Subject: [PATCH 26/29] Code style fix #782 --- Source/Editor/Windows/EditGameWindow.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Editor/Windows/EditGameWindow.cs b/Source/Editor/Windows/EditGameWindow.cs index 6103129c1..3c0d40c9d 100644 --- a/Source/Editor/Windows/EditGameWindow.cs +++ b/Source/Editor/Windows/EditGameWindow.cs @@ -151,17 +151,17 @@ namespace FlaxEditor.Windows Viewport.Task.ViewFlags = ViewFlags.DefaultEditor; Editor.SceneEditing.SelectionChanged += OnSelectionChanged; - Editor.Scene.ActorRemoved += SceneOnActorRemoved; } - + /// public override void OnEditorStateChanged() { base.OnEditorStateChanged(); + UpdateCameraPreview(); } - + private void OnSelectionChanged() { UpdateCameraPreview(); From 1fb19ee023735452565c420557283538569ffa40 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 23 Oct 2022 22:38:38 +0200 Subject: [PATCH 27/29] Adjust content view items to whole pixels to reduce text aliasing #794 --- Source/Editor/Content/GUI/ContentView.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Editor/Content/GUI/ContentView.cs b/Source/Editor/Content/GUI/ContentView.cs index 6825910bc..a7dc7b18f 100644 --- a/Source/Editor/Content/GUI/ContentView.cs +++ b/Source/Editor/Content/GUI/ContentView.cs @@ -718,11 +718,11 @@ namespace FlaxEditor.Content.GUI float defaultItemsWidth = ContentItem.DefaultWidth * viewScale; int itemsToFit = Mathf.FloorToInt(width / defaultItemsWidth) - 1; if (itemsToFit < 1) - { itemsToFit = 1; - } float itemsWidth = width / Mathf.Max(itemsToFit, 1); + itemsWidth = Mathf.Floor(itemsWidth); float itemsHeight = itemsWidth / defaultItemsWidth * (ContentItem.DefaultHeight * viewScale); + itemsHeight = Mathf.Floor(itemsHeight); x = itemsToFit == 1 ? 0 : itemsWidth / itemsToFit; for (int i = 0; i < _children.Count; i++) { From 6f380a6f12681ede4366401e03457a8f9e3b33bd Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 23 Oct 2022 23:46:11 +0200 Subject: [PATCH 28/29] Code style fix #783 --- Source/Editor/GUI/Input/ValueBox.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Editor/GUI/Input/ValueBox.cs b/Source/Editor/GUI/Input/ValueBox.cs index 1e9553d22..5038dab20 100644 --- a/Source/Editor/GUI/Input/ValueBox.cs +++ b/Source/Editor/GUI/Input/ValueBox.cs @@ -229,7 +229,7 @@ namespace FlaxEditor.GUI.Input // Update UpdateText(); } - + Cursor = CursorType.Default; ResetViewOffset(); @@ -245,12 +245,12 @@ namespace FlaxEditor.GUI.Input _startSlideLocation = location; _startSlideValue = _value; StartMouseCapture(true); - + // Hide cursor and cache location Cursor = CursorType.Hidden; _mouseClickedPosition = location; _cursorChanged = true; - + SlidingStart?.Invoke(); return true; } @@ -271,7 +271,7 @@ namespace FlaxEditor.GUI.Input ApplySliding(Mathf.RoundToInt(slideLocation.X - _startSlideLocation.X) * _slideSpeed); return; } - + // Update cursor type so user knows they can slide value if (CanUseSliding && SlideRect.Contains(location) && !_isSliding) { From b7b31aad8ec5b7503485ff60a4efd13c01bd170d Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 23 Oct 2022 23:49:46 +0200 Subject: [PATCH 29/29] Code style fix #793 --- Source/Editor/GUI/ContextMenu/ContextMenuBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs b/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs index 400bf56cb..1093b50b7 100644 --- a/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs +++ b/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs @@ -159,7 +159,7 @@ namespace FlaxEditor.GUI.ContextMenu { // Direction: left isLeft = true; - + if (IsSubMenu && _parentCM != null) { locationSS.X -= _parentCM.Width + dpiSize.X;