From 252de16c135cd2785bd91e8e1ce4b5cbed67f0df Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Tue, 20 Aug 2024 20:40:50 -0500 Subject: [PATCH] Fix bugs with quaternion editor. --- .../Editor/CustomEditors/Editors/QuaternionEditor.cs | 10 +++++++++- Source/Editor/CustomEditors/Editors/Vector3Editor.cs | 6 ------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Source/Editor/CustomEditors/Editors/QuaternionEditor.cs b/Source/Editor/CustomEditors/Editors/QuaternionEditor.cs index 704e1c803..1edf18c03 100644 --- a/Source/Editor/CustomEditors/Editors/QuaternionEditor.cs +++ b/Source/Editor/CustomEditors/Editors/QuaternionEditor.cs @@ -61,6 +61,7 @@ namespace FlaxEditor.CustomEditors.Editors _slidingEnded = true; ClearToken(); }; + _defaultSlidingSpeed = XElement.ValueBox.SlideSpeed; YElement = grid.FloatValue(); YElement.ValueBox.Category = Utils.ValueCategory.Angle; @@ -270,7 +271,7 @@ namespace FlaxEditor.CustomEditors.Editors Float3 average = Float3.Zero; for (int i = 0; i < Values.Count; i++) { - var value = (Quaternion)Values[0]; + var value = (Quaternion)Values[i]; var euler = value.EulerAngles; average += euler; @@ -337,6 +338,13 @@ namespace FlaxEditor.CustomEditors.Editors XElement.ValueBox.Value = euler.X; YElement.ValueBox.Value = euler.Y; ZElement.ValueBox.Value = euler.Z; + + if (!Mathf.NearEqual(XElement.ValueBox.SlideSpeed, _defaultSlidingSpeed)) + XElement.ValueBox.SlideSpeed = _defaultSlidingSpeed; + if (!Mathf.NearEqual(YElement.ValueBox.SlideSpeed, _defaultSlidingSpeed)) + YElement.ValueBox.SlideSpeed = _defaultSlidingSpeed; + if (!Mathf.NearEqual(ZElement.ValueBox.SlideSpeed, _defaultSlidingSpeed)) + ZElement.ValueBox.SlideSpeed = _defaultSlidingSpeed; } } } diff --git a/Source/Editor/CustomEditors/Editors/Vector3Editor.cs b/Source/Editor/CustomEditors/Editors/Vector3Editor.cs index 0e8104fa6..8f002a2d4 100644 --- a/Source/Editor/CustomEditors/Editors/Vector3Editor.cs +++ b/Source/Editor/CustomEditors/Editors/Vector3Editor.cs @@ -444,17 +444,11 @@ namespace FlaxEditor.CustomEditors.Editors ZElement.ValueBox.Value = value.Z; if (!Mathf.NearEqual(XElement.ValueBox.SlideSpeed, _defaultSlidingSpeed)) - { XElement.ValueBox.SlideSpeed = _defaultSlidingSpeed; - } if (!Mathf.NearEqual(YElement.ValueBox.SlideSpeed, _defaultSlidingSpeed)) - { YElement.ValueBox.SlideSpeed = _defaultSlidingSpeed; - } if (!Mathf.NearEqual(ZElement.ValueBox.SlideSpeed, _defaultSlidingSpeed)) - { ZElement.ValueBox.SlideSpeed = _defaultSlidingSpeed; - } } } }