diff --git a/Source/Editor/CustomEditors/Dedicated/CurveObjectEditor.cs b/Source/Editor/CustomEditors/Dedicated/CurveObjectEditor.cs index 81d826a04..a39297572 100644 --- a/Source/Editor/CustomEditors/Dedicated/CurveObjectEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/CurveObjectEditor.cs @@ -15,13 +15,23 @@ namespace FlaxEditor.CustomEditors.Dedicated private int _firstTimeShow; private BezierCurveEditor _curve; private Splitter _splitter; + private string _heightCachedPath; /// public override void Initialize(LayoutElementsContainer layout) { var item = layout.CustomContainer>(); _curve = item.CustomControl; - _curve.Height = 120.0f; + var height = 120.0f; + var presenter = Presenter; + if (presenter != null && (presenter.Features & FeatureFlags.CacheExpandedGroups) != 0) + { + // Try to restore curve height + _heightCachedPath = layout.GetLayoutCachePath("Height"); + if (Editor.Instance.ProjectCache.TryGetCustomData(_heightCachedPath, out float cachedHeight) && cachedHeight > 10.0f) + height = cachedHeight; + } + _curve.Height = height; _curve.Edited += OnCurveEdited; _firstTimeShow = 4; // For some weird reason it needs several frames of warmup (probably due to sliders smoothing) _splitter = new Splitter @@ -45,7 +55,11 @@ namespace FlaxEditor.CustomEditors.Dedicated private void OnSplitterMoved(Float2 location) { - _curve.Height = Mathf.Clamp(_splitter.PointToParent(location).Y, 50.0f, 1000.0f); + _curve.Height = Mathf.Clamp(_splitter.PointToParent(location).Y, 50.0f, 1000.0f); + + // Cache curve height + if (_heightCachedPath != null) + Editor.Instance.ProjectCache.SetCustomData(_heightCachedPath, _curve.Height); } /// @@ -133,13 +147,23 @@ namespace FlaxEditor.CustomEditors.Dedicated private int _firstTimeShow; private LinearCurveEditor _curve; private Splitter _splitter; + private string _heightCachedPath; /// public override void Initialize(LayoutElementsContainer layout) { var item = layout.CustomContainer>(); _curve = item.CustomControl; - _curve.Height = 120.0f; + var height = 120.0f; + var presenter = Presenter; + if (presenter != null && (presenter.Features & FeatureFlags.CacheExpandedGroups) != 0) + { + // Try to restore curve height + _heightCachedPath = layout.GetLayoutCachePath("Height"); + if (Editor.Instance.ProjectCache.TryGetCustomData(_heightCachedPath, out float cachedHeight) && cachedHeight > 10.0f) + height = cachedHeight; + } + _curve.Height = height; _curve.Edited += OnCurveEdited; _firstTimeShow = 4; // For some weird reason it needs several frames of warmup (probably due to sliders smoothing) _splitter = new Splitter @@ -164,6 +188,10 @@ namespace FlaxEditor.CustomEditors.Dedicated private void OnSplitterMoved(Float2 location) { _curve.Height = Mathf.Clamp(_splitter.PointToParent(location).Y, 50.0f, 1000.0f); + + // Cache curve height + if (_heightCachedPath != null) + Editor.Instance.ProjectCache.SetCustomData(_heightCachedPath, _curve.Height); } /// diff --git a/Source/Editor/CustomEditors/LayoutElementsContainer.cs b/Source/Editor/CustomEditors/LayoutElementsContainer.cs index 5b0e2f742..9fa090902 100644 --- a/Source/Editor/CustomEditors/LayoutElementsContainer.cs +++ b/Source/Editor/CustomEditors/LayoutElementsContainer.cs @@ -96,6 +96,20 @@ namespace FlaxEditor.CustomEditors menu.Show(groupPanel, location); } + internal string GetLayoutCachePath(string name) + { + // Build group identifier (made of path from group titles) + var expandPath = name; + var container = this; + while (container != null && !(container is CustomEditorPresenter)) + { + if (container.ContainerControl is DropPanel dropPanel) + expandPath = dropPanel.HeaderText + "/" + expandPath; + container = container._parent; + } + return expandPath; + } + /// /// Adds new group element. /// @@ -112,14 +126,7 @@ namespace FlaxEditor.CustomEditors if (presenter != null && (presenter.Features & FeatureFlags.CacheExpandedGroups) != 0) { // Build group identifier (made of path from group titles) - var expandPath = title; - var container = this; - while (container != null && !(container is CustomEditorPresenter)) - { - if (container.ContainerControl is DropPanel dropPanel) - expandPath = dropPanel.HeaderText + "/" + expandPath; - container = container._parent; - } + var expandPath = GetLayoutCachePath(title); // Caching/restoring expanded groups (non-root groups cache expanded state so invert boolean expression) if (Editor.Instance.ProjectCache.IsGroupToggled(expandPath) ^ isSubGroup)