From 850107944c9fd95462e15c3a5212ad38e3c1a546 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 15 Aug 2024 21:44:40 -0500 Subject: [PATCH 1/2] Hide parameters for animated model on end play. --- .../Dedicated/AnimatedModelEditor.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Source/Editor/CustomEditors/Dedicated/AnimatedModelEditor.cs b/Source/Editor/CustomEditors/Dedicated/AnimatedModelEditor.cs index 6f1ac91d0..8a6508346 100644 --- a/Source/Editor/CustomEditors/Dedicated/AnimatedModelEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/AnimatedModelEditor.cs @@ -1,5 +1,7 @@ // Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. +using System; +using FlaxEditor.CustomEditors.Elements; using FlaxEditor.Surface; using FlaxEngine; @@ -33,5 +35,21 @@ namespace FlaxEditor.CustomEditors.Dedicated Values); } } + + /// + public override void Refresh() + { + base.Refresh(); + + // Check if parameters group is still showing if not in play mode and hide it. + if (!Editor.Instance.StateMachine.IsPlayMode) + { + var group = Layout.Children.Find(x => x is GroupElement g && g.Panel.HeaderText.Equals("Parameters", StringComparison.Ordinal)); + if (group != null) + { + RebuildLayout(); + } + } + } } } From fb9cc7fea5f6ddd7654fdf1512a531be82813221 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Thu, 15 Aug 2024 21:48:25 -0500 Subject: [PATCH 2/2] Add boolean check for if paramters are showing. --- .../Editor/CustomEditors/Dedicated/AnimatedModelEditor.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Editor/CustomEditors/Dedicated/AnimatedModelEditor.cs b/Source/Editor/CustomEditors/Dedicated/AnimatedModelEditor.cs index 8a6508346..3070fd19a 100644 --- a/Source/Editor/CustomEditors/Dedicated/AnimatedModelEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/AnimatedModelEditor.cs @@ -14,6 +14,8 @@ namespace FlaxEditor.CustomEditors.Dedicated [CustomEditor(typeof(AnimatedModel)), DefaultEditor] public class AnimatedModelEditor : ActorEditor { + private bool _parametersAdded = false; + /// public override void Initialize(LayoutElementsContainer layout) { @@ -33,6 +35,7 @@ namespace FlaxEditor.CustomEditors.Dedicated (instance, parameter, tag) => ((AnimatedModel)instance).GetParameterValue(parameter.Identifier), (instance, value, parameter, tag) => ((AnimatedModel)instance).SetParameterValue(parameter.Identifier, value), Values); + _parametersAdded = true; } } @@ -42,12 +45,13 @@ namespace FlaxEditor.CustomEditors.Dedicated base.Refresh(); // Check if parameters group is still showing if not in play mode and hide it. - if (!Editor.Instance.StateMachine.IsPlayMode) + if (!Editor.Instance.StateMachine.IsPlayMode && _parametersAdded) { var group = Layout.Children.Find(x => x is GroupElement g && g.Panel.HeaderText.Equals("Parameters", StringComparison.Ordinal)); if (group != null) { RebuildLayout(); + _parametersAdded = false; } } }