diff --git a/Source/Editor/Surface/Archetypes/Animation.MultiBlend.cs b/Source/Editor/Surface/Archetypes/Animation.MultiBlend.cs index b34766d53..ffb04c6af 100644 --- a/Source/Editor/Surface/Archetypes/Animation.MultiBlend.cs +++ b/Source/Editor/Surface/Archetypes/Animation.MultiBlend.cs @@ -570,7 +570,7 @@ namespace FlaxEditor.Surface.Archetypes var icon = Editor.Instance.Icons.VisjectBoxOpen32; var size = BlendPoint.DefaultSize * _debugScale; var debugPos = BlendSpacePosToBlendPointPos(_debugPos); - var debugRect = new Rectangle(debugPos + new Float2(size * -0.5f) + size * 0.5f, new Float2(size)); + var debugRect = new Rectangle(debugPos + new Float2(size * -0.5f), new Float2(size)); var outline = Color.Black; // Shadow Render2D.DrawSprite(icon, debugRect.MakeExpanded(2.0f), outline); Render2D.DrawSprite(icon, debugRect, style.ProgressNormal); diff --git a/Source/Editor/Surface/VisjectSurface.Context.cs b/Source/Editor/Surface/VisjectSurface.Context.cs index 3fe29adaa..8bcdb3bc9 100644 --- a/Source/Editor/Surface/VisjectSurface.Context.cs +++ b/Source/Editor/Surface/VisjectSurface.Context.cs @@ -228,6 +228,13 @@ namespace FlaxEditor.Surface /// protected virtual void OnContextChanged() { + // Cache viewport of the context (used to restore when leaving it) + if (_context != null) + { + _context._cachedViewCenterPosition = ViewCenterPosition; + _context._cachedViewScale = ViewScale; + } + var context = ContextStack.Count > 0 ? ContextStack.Peek() : null; _context = context; if (ContextStack.Count == 0) @@ -249,6 +256,18 @@ namespace FlaxEditor.Surface } ContextChanged?.Invoke(_context); + + // Restore viewport in the context + if (_context?._cachedViewScale > 0.0f) + { + ViewScale = _context._cachedViewScale; + ViewCenterPosition = _context._cachedViewCenterPosition; + } + else + { + // Show whole surface on load + ShowWholeGraph(); + } } } } diff --git a/Source/Editor/Surface/VisjectSurfaceContext.cs b/Source/Editor/Surface/VisjectSurfaceContext.cs index d9259e637..e21564ce2 100644 --- a/Source/Editor/Surface/VisjectSurfaceContext.cs +++ b/Source/Editor/Surface/VisjectSurfaceContext.cs @@ -29,6 +29,8 @@ namespace FlaxEditor.Surface private bool _isModified; private VisjectSurface _surface; private SurfaceMeta _meta = new SurfaceMeta(); + internal Float2 _cachedViewCenterPosition; + internal float _cachedViewScale = -1; // Negative scale to indicate missing data (will show whole surface on start) /// /// The parent context. Defines the higher key surface graph context. May be null for the top-level context. diff --git a/Source/Editor/Windows/Assets/AnimationGraphWindow.cs b/Source/Editor/Windows/Assets/AnimationGraphWindow.cs index f27c3158f..9e1ac6a54 100644 --- a/Source/Editor/Windows/Assets/AnimationGraphWindow.cs +++ b/Source/Editor/Windows/Assets/AnimationGraphWindow.cs @@ -371,6 +371,9 @@ namespace FlaxEditor.Windows.Assets // Update navbar _surface.UpdateNavigationBar(_navigationBar, _toolstrip); + // Show whole model + _preview.ResetCamera(); + return false; } @@ -437,6 +440,16 @@ namespace FlaxEditor.Windows.Assets _debugFlows.Clear(); } + // Update preview values when debugging specific instance + if (debugActor != null && debugActor != _preview.PreviewActor) + { + var parameters = debugActor.Parameters; + foreach (var p in parameters) + { + _preview.PreviewActor.SetParameterValue(p.Identifier, p.Value); + } + } + _showNodesButton.Checked = _preview.ShowNodes; } diff --git a/Source/Engine/Core/Collections/ArrayExtensions.h b/Source/Engine/Core/Collections/ArrayExtensions.h index e8bd9ce45..d00b2af93 100644 --- a/Source/Engine/Core/Collections/ArrayExtensions.h +++ b/Source/Engine/Core/Collections/ArrayExtensions.h @@ -67,7 +67,7 @@ public: /// The prediction function. Should return true for the target element to find. /// The first found item or default value if nothing found. template - static T First(const Array& obj, const Function predicate) + static T First(const Array& obj, const Function& predicate) { for (int32 i = 0; i < obj.Count(); i++) { @@ -84,7 +84,7 @@ public: /// The prediction function. Should return true for the target element to find. /// The first found item or default value if nothing found. template - static T* First(const Array& obj, const Function predicate) + static T* First(const Array& obj, const Function& predicate) { for (int32 i = 0; i < obj.Count(); i++) {