Skip to content

Commit 63649e7

Browse files
author
Unity Technologies
committed
com.unity.splines@2.6.1
## [2.6.1] - 2024-05-23 ### Bug Fixes - [SPLB-275] Fixed a bug where the `SplineContainer` component would throw warning when entering playmode. - [SPLB-266] Fixed a bug where instantiating a `SplineExtrude` component at runtime would throw errors. - [SPLB-269] Fixed a bug where instantiating a `SplineAnimate` component at runtime would throw errors. - [SPLB-260] Fixed a bug where playing a `SplineAnimate` from a start method would not work. - [SPLB-267] Fixed a bug where undoing a spline insertion in a container would throw errors from the `SplineInstantiate` component. - [SPLB-261] Fixed a bug where the knot placement tool would not work when multiple scene views were opened. - [SPLB-253] Fixed a bug where using the knot placement tool in 2D mode would not work if the grids are turned off. - [SPLB-258] Fixed a bug where destroying a component would throw errors in the console.
1 parent 5af4810 commit 63649e7

18 files changed

+183
-83
lines changed

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,20 @@ All notable changes to this package will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8-
## [2.6.0] - 2023-04-15
8+
## [2.6.1] - 2024-05-23
9+
10+
### Bug Fixes
11+
12+
- [SPLB-275] Fixed a bug where the `SplineContainer` component would throw warning when entering playmode.
13+
- [SPLB-266] Fixed a bug where instantiating a `SplineExtrude` component at runtime would throw errors.
14+
- [SPLB-269] Fixed a bug where instantiating a `SplineAnimate` component at runtime would throw errors.
15+
- [SPLB-260] Fixed a bug where playing a `SplineAnimate` from a start method would not work.
16+
- [SPLB-267] Fixed a bug where undoing a spline insertion in a container would throw errors from the `SplineInstantiate` component.
17+
- [SPLB-261] Fixed a bug where the knot placement tool would not work when multiple scene views were opened.
18+
- [SPLB-253] Fixed a bug where using the knot placement tool in 2D mode would not work if the grids are turned off.
19+
- [SPLB-258] Fixed a bug where destroying a component would throw errors in the console.
20+
21+
## [2.6.0] - 2024-04-15
922

1023
### Added
1124

Editor/Components/SplineAnimateEditor.cs

Lines changed: 83 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34
using UnityEngine.Splines;
45
using UnityEditor.UIElements;
@@ -11,12 +12,11 @@ namespace UnityEditor.Splines
1112
[CanEditMultipleObjects]
1213
class SplineAnimateEditor : UnityEditor.Editor
1314
{
14-
VisualElement m_Root;
15-
Button m_PlayButton;
16-
Slider m_ProgressSlider;
17-
FloatField m_ElapsedTimeField;
18-
EnumField m_ObjectForwardField;
19-
EnumField m_ObjectUpField;
15+
List<VisualElement> m_Roots = new ();
16+
List<Slider> m_ProgressSliders = new ();
17+
List<FloatField> m_ElapsedTimeFields = new ();
18+
List<EnumField> m_ObjectForwardFields = new ();
19+
List<EnumField> m_ObjectUpFields = new ();
2020

2121
SerializedProperty m_MethodProperty;
2222
SerializedProperty m_ObjectForwardProperty;
@@ -59,7 +59,13 @@ void OnEnable()
5959
if (animate.Container != null)
6060
animate.RecalculateAnimationParameters();
6161
}
62-
62+
63+
m_Roots.Clear();
64+
m_ObjectForwardFields.Clear();
65+
m_ObjectUpFields.Clear();
66+
m_ProgressSliders.Clear();
67+
m_ElapsedTimeFields.Clear();
68+
6369
EditorApplication.update += OnEditorUpdate;
6470
Spline.Changed += OnSplineChange;
6571
SplineContainer.SplineAdded += OnContainerSplineSetModified;
@@ -99,7 +105,7 @@ void OnEditorUpdate()
99105
RefreshProgressFields();
100106
}
101107
}
102-
else
108+
else if(m_SplineAnimate.IsPlaying)
103109
RefreshProgressFields();
104110
}
105111

@@ -129,77 +135,101 @@ void OnContainerSplineSetModified(SplineContainer container, int spline)
129135

130136
public override VisualElement CreateInspectorGUI()
131137
{
132-
m_Root = new VisualElement();
138+
var root = new VisualElement();
133139

134140
if (s_TreeAsset == null)
135141
s_TreeAsset = (VisualTreeAsset)AssetDatabase.LoadAssetAtPath(k_UxmlPath, typeof(VisualTreeAsset));
136-
s_TreeAsset.CloneTree(m_Root);
142+
s_TreeAsset.CloneTree(root);
137143

138144
if (s_ThemeStyleSheet == null)
139145
s_ThemeStyleSheet = AssetDatabase.LoadAssetAtPath<StyleSheet>($"Packages/com.unity.splines/Editor/Stylesheets/SplineAnimateInspector{(EditorGUIUtility.isProSkin ? "Dark" : "Light")}.uss");
140146

141-
m_Root.styleSheets.Add(s_ThemeStyleSheet);
147+
root.styleSheets.Add(s_ThemeStyleSheet);
142148

143-
var methodField = m_Root.Q<PropertyField>("method");
149+
var methodField = root.Q<PropertyField>("method");
144150
methodField.RegisterValueChangeCallback((_) => { RefreshMethodParamFields((SplineAnimate.Method)m_MethodProperty.enumValueIndex); });
145151
RefreshMethodParamFields((SplineAnimate.Method)m_MethodProperty.enumValueIndex);
146152

147-
m_ObjectForwardField = m_Root.Q<EnumField>("object-forward");
148-
m_ObjectForwardField.RegisterValueChangedCallback((evt) => OnObjectAxisFieldChange(evt, m_ObjectForwardProperty, m_ObjectUpProperty));
149-
150-
m_ObjectUpField = m_Root.Q<EnumField>("object-up");
151-
m_ObjectUpField.RegisterValueChangedCallback((evt) => OnObjectAxisFieldChange(evt, m_ObjectUpProperty, m_ObjectForwardProperty));
153+
var objectForwardField = root.Q<EnumField>("object-forward");
154+
objectForwardField.RegisterValueChangedCallback((evt) => OnObjectAxisFieldChange(evt, m_ObjectForwardProperty, m_ObjectUpProperty));
152155

153-
var startOffsetField = m_Root.Q<PropertyField>("start-offset");
154-
startOffsetField.RegisterValueChangeCallback((_) =>
155-
{
156-
m_SplineAnimate.StartOffset = m_StartOffsetProperty.floatValue;
157-
m_SplineAnimate.Restart(false);
158-
OnElapsedTimeFieldChange(m_ElapsedTimeField.value);
159-
});
156+
var objectUpField = root.Q<EnumField>("object-up");
157+
objectUpField.RegisterValueChangedCallback((evt) => OnObjectAxisFieldChange(evt, m_ObjectUpProperty, m_ObjectForwardProperty));
160158

161-
var playButton = m_Root.Q<Button>("play");
159+
var playButton = root.Q<Button>("play");
160+
playButton.SetEnabled(!EditorApplication.isPlaying);
162161
playButton.clicked += OnPlayClicked;
163162

164-
var pauseButton = m_Root.Q<Button>("pause");
163+
var pauseButton = root.Q<Button>("pause");
164+
pauseButton.SetEnabled(!EditorApplication.isPlaying);
165165
pauseButton.clicked += OnPauseClicked;
166166

167-
var resetButton = m_Root.Q<Button>("reset");
167+
var resetButton = root.Q<Button>("reset");
168+
resetButton.SetEnabled(!EditorApplication.isPlaying);
168169
resetButton.clicked += OnResetClicked;
169170

170-
m_ProgressSlider = m_Root.Q<Slider>("normalized-progress");
171-
m_ProgressSlider.RegisterValueChangedCallback((evt) => OnProgressSliderChange(evt.newValue));
171+
var progressSlider = root.Q<Slider>("normalized-progress");
172+
progressSlider.SetEnabled(!EditorApplication.isPlaying);
173+
progressSlider.RegisterValueChangedCallback((evt) => OnProgressSliderChange(evt.newValue));
172174

173-
m_ElapsedTimeField = m_Root.Q<FloatField>("elapsed-time");
174-
m_ElapsedTimeField.RegisterValueChangedCallback((evt) => OnElapsedTimeFieldChange(evt.newValue));
175+
var elapsedTimeField = root.Q<FloatField>("elapsed-time");
176+
elapsedTimeField.SetEnabled(!EditorApplication.isPlaying);
177+
elapsedTimeField.RegisterValueChangedCallback((evt) => OnElapsedTimeFieldChange(evt.newValue));
175178

176-
return m_Root;
179+
var startOffsetField = root.Q<PropertyField>("start-offset");
180+
startOffsetField.RegisterValueChangeCallback((evt) =>
181+
{
182+
m_SplineAnimate.StartOffset = m_StartOffsetProperty.floatValue;
183+
if (!EditorApplication.isPlayingOrWillChangePlaymode)
184+
{
185+
m_SplineAnimate.Restart(false);
186+
OnElapsedTimeFieldChange(elapsedTimeField.value);
187+
}
188+
});
189+
190+
m_Roots.Add(root);
191+
m_ProgressSliders.Add(progressSlider);
192+
m_ElapsedTimeFields.Add(elapsedTimeField);
193+
194+
m_ObjectForwardFields.Add(objectForwardField);
195+
m_ObjectUpFields.Add(objectUpField);
196+
197+
return root;
177198
}
178199

179200
void RefreshMethodParamFields(SplineAnimate.Method method)
180201
{
181-
var durationField = m_Root.Q<PropertyField>("duration");
182-
var maxSpeedField = m_Root.Q<PropertyField>("max-speed");
183-
184-
if (method == (int) SplineAnimate.Method.Time)
202+
foreach (var root in m_Roots)
185203
{
186-
durationField.style.display = DisplayStyle.Flex;
187-
maxSpeedField.style.display = DisplayStyle.None;
188-
}
189-
else
190-
{
191-
durationField.style.display = DisplayStyle.None;
192-
maxSpeedField.style.display = DisplayStyle.Flex;
204+
205+
var durationField = root.Q<PropertyField>("duration");
206+
var maxSpeedField = root.Q<PropertyField>("max-speed");
207+
208+
if (method == (int)SplineAnimate.Method.Time)
209+
{
210+
durationField.style.display = DisplayStyle.Flex;
211+
maxSpeedField.style.display = DisplayStyle.None;
212+
}
213+
else
214+
{
215+
durationField.style.display = DisplayStyle.None;
216+
maxSpeedField.style.display = DisplayStyle.Flex;
217+
}
193218
}
194219
}
195220

196221
void RefreshProgressFields()
197222
{
198-
if (m_ProgressSlider == null || m_ElapsedTimeField == null)
199-
return;
223+
for (int i = 0; i < m_ProgressSliders.Count && i < m_ElapsedTimeFields.Count; ++i)
224+
{
225+
var progressSlider = m_ProgressSliders[i];
226+
var elapsedTimeField = m_ElapsedTimeFields[i];
227+
if (progressSlider == null || elapsedTimeField == null)
228+
continue;
200229

201-
m_ProgressSlider.SetValueWithoutNotify(m_SplineAnimate.GetLoopInterpolation(false));
202-
m_ElapsedTimeField.SetValueWithoutNotify(m_SplineAnimate.ElapsedTime);
230+
progressSlider.SetValueWithoutNotify(m_SplineAnimate.GetLoopInterpolation(false));
231+
elapsedTimeField.SetValueWithoutNotify(m_SplineAnimate.ElapsedTime);
232+
}
203233
}
204234

205235
void OnProgressSliderChange(float progress)
@@ -223,6 +253,7 @@ void OnObjectAxisFieldChange(ChangeEvent<Enum> changeEvent, SerializedProperty a
223253
if (changeEvent.newValue == null)
224254
return;
225255

256+
226257
var newValue = (SplineAnimate.AlignAxis)changeEvent.newValue;
227258
var previousValue = (SplineAnimate.AlignAxis)changeEvent.previousValue;
228259

@@ -238,6 +269,11 @@ void OnObjectAxisFieldChange(ChangeEvent<Enum> changeEvent, SerializedProperty a
238269
axisProp.enumValueIndex = (int)previousValue;
239270
serializedObject.ApplyModifiedPropertiesWithoutUndo();
240271
}
272+
273+
foreach (var objectForwardField in m_ObjectForwardFields)
274+
objectForwardField.SetValueWithoutNotify((SplineComponent.AlignAxis)m_ObjectForwardProperty.enumValueIndex);
275+
foreach (var objectUpField in m_ObjectUpFields)
276+
objectUpField.SetValueWithoutNotify((SplineComponent.AlignAxis)m_ObjectUpProperty.enumValueIndex);
241277
}
242278

243279
void OnPlayClicked()
File renamed without changes.
File renamed without changes.

Editor/Components/SplineContainerEditor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ void UndoRedoPerformed()
5353
var container = t as SplineContainer;
5454
if (container != null)
5555
{
56+
container.ClearCaches();
5657
foreach (var spline in container.Splines)
5758
spline.SetDirty(SplineModification.Default);
5859
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

Editor/Resources/UI/UXML/splineanimate-inspector.uxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
<ui:VisualElement class="field__indented" style="flex-direction: row; flex-shrink: 0; margin-top: 3px;">
2323
<ui:Slider picking-mode="Ignore" value="0" high-value="1" show-input-field="false" name="normalized-progress" style="margin-bottom: 0; margin-top: 2px; flex-grow: 1;" />
2424
<ui:Label text="Time:" display-tooltip-when-elided="true" style="-unity-text-align: middle-left; margin-left: 4px;" />
25-
<uie:FloatField value="0" name="elapsed-time" style="-unity-text-align: upper-left; align-items: stretch; justify-content: flex-start; width: 40px;" />
25+
<uie:FloatField name="elapsed-time" is-delayed="true" style="-unity-text-align: upper-left; align-items: stretch; justify-content: flex-start; width: 40px;" />
2626
</ui:VisualElement>
2727
</ui:UXML>

0 commit comments

Comments
 (0)