Skip to content

Commit 40d982d

Browse files
author
Unity Technologies
committed
com.unity.splines@2.7.2
## [2.7.2] - 2024-11-08 ### Bug Fixes - [SPLB-315] Fixed a bug where the `DrawSplineTool` icon was missing in the tools overlay. - [STO-3434] Fixed a bug where the `DrawSplineTool` would prevent the use of the view tool. - [STO-3435] Fixed a bug where the `DrawSplineTool` would not display the tool settings anymore. - [SPLB-296] Fixed a bug where a log message would appear in the console when 2 knots are at the same position with 0-length tangents. - [SPLB-304] Fixed a bug where an exception would be thrown when using `SplineInstantiate` with linear distance instantiate method and multiple splines. - Fixed some failures related to the inline API documentation. - [SPLB-302] Fixed a bug where an exception would be thrown when adding a knot to a closed spline from inspector. - [SPLB-311] Fixed a bug where `SplineAnimate` component would not function properly with non-uniform scale transforms. - Fixed compilation errors in builds - [SPLB-310] Fixed mesh extrude not being saved when a change is applied to a mesh asset. - [SPLB-303] Fixed a bug where spline section foldout labels (shape extrude, geometry, advanced) did not unfold the sections when clicked. - [SPLB-294] Fixed a bug where adding new splines by using the `SplineContainer` inspector would dirty all open scenes.
1 parent 4252b75 commit 40d982d

27 files changed

+206
-148
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ 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.7.2] - 2024-11-08
9+
10+
### Bug Fixes
11+
- [SPLB-315] Fixed a bug where the `DrawSplineTool` icon was missing in the tools overlay.
12+
- [STO-3434] Fixed a bug where the `DrawSplineTool` would prevent the use of the view tool.
13+
- [STO-3435] Fixed a bug where the `DrawSplineTool` would not display the tool settings anymore.
14+
- [SPLB-296] Fixed a bug where a log message would appear in the console when 2 knots are at the same position with 0-length tangents.
15+
- [SPLB-304] Fixed a bug where an exception would be thrown when using `SplineInstantiate` with linear distance instantiate method and multiple splines.
16+
- Fixed some failures related to the inline API documentation.
17+
- [SPLB-302] Fixed a bug where an exception would be thrown when adding a knot to a closed spline from inspector.
18+
- [SPLB-311] Fixed a bug where `SplineAnimate` component would not function properly with non-uniform scale transforms.
19+
- Fixed compilation errors in builds
20+
- [SPLB-310] Fixed mesh extrude not being saved when a change is applied to a mesh asset.
21+
- [SPLB-303] Fixed a bug where spline section foldout labels (shape extrude, geometry, advanced) did not unfold the sections when clicked.
22+
- [SPLB-294] Fixed a bug where adding new splines by using the `SplineContainer` inspector would dirty all open scenes.
23+
824
## [2.7.1] - 2024-10-17
925

1026
### Added

Editor/Components/SplineExtrudeEditor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public override void OnInspectorGUI()
156156
EditorGUILayout.HelpBox(k_Helpbox, MessageType.Warning);
157157

158158
// shape section
159-
m_Shape.isExpanded = Foldout(m_Shape.isExpanded, k_ShapeContent);
159+
m_Shape.isExpanded = Foldout(m_Shape.isExpanded, k_ShapeContent, true);
160160

161161
if (m_Shape.isExpanded)
162162
{
@@ -181,7 +181,7 @@ public override void OnInspectorGUI()
181181
EditorGUILayout.Space(4);
182182

183183
// geometry section
184-
m_Radius.isExpanded = Foldout(m_Radius.isExpanded, k_GeometryContent);
184+
m_Radius.isExpanded = Foldout(m_Radius.isExpanded, k_GeometryContent, true);
185185

186186
if (m_Radius.isExpanded)
187187
{
@@ -247,7 +247,7 @@ public override void OnInspectorGUI()
247247
// advanced section
248248
EditorGUILayout.Space(4);
249249

250-
m_Range.isExpanded = Foldout(m_Range.isExpanded, k_AdvancedContent);
250+
m_Range.isExpanded = Foldout(m_Range.isExpanded, k_AdvancedContent, true);
251251

252252
if (m_Range.isExpanded)
253253
{

Editor/GUI/Editors/SplineReorderableList.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void OnReorder(ReorderableList reorderableList, int srcIndex, int dstIndex)
8282
if (m_Container == null)
8383
return;
8484

85-
Undo.RecordObject(serializedProperty.serializedObject.targetObject, "Reordering Spline in SplineContainer");
85+
Undo.RegisterCompleteObjectUndo(serializedProperty.serializedObject.targetObject, "Reordering Spline in SplineContainer");
8686
m_Container.ReorderSpline(srcIndex, dstIndex);
8787
serializedProperty.serializedObject.ApplyModifiedProperties();
8888
serializedProperty.serializedObject.Update();
@@ -102,7 +102,7 @@ internal void OnAdd(ReorderableList _)
102102
if(m_Container == null)
103103
return;
104104

105-
Undo.RecordObject(serializedProperty.serializedObject.targetObject, "Add new Spline");
105+
Undo.RegisterCompleteObjectUndo(serializedProperty.serializedObject.targetObject, "Add new Spline");
106106

107107
int added = 0;
108108

@@ -139,7 +139,7 @@ internal void OnRemove(ReorderableList _)
139139
if (m_Container == null)
140140
return;
141141

142-
Undo.RecordObject(serializedProperty.serializedObject.targetObject, "Removing Spline from SplineContainer");
142+
Undo.RegisterCompleteObjectUndo(serializedProperty.serializedObject.targetObject, "Removing Spline from SplineContainer");
143143

144144
for (int i = selectedIndices.Count - 1; i >= 0; i--)
145145
m_Container.RemoveSplineAt(selectedIndices[i]);

Editor/GUI/SplineDataHandles.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ public static class SplineDataHandles
2727
/// on the spline adds a new DataPoint in the SplineData. Left click on an existing DataPoint
2828
/// allows to move this point along the Spline while a right click on it allows to delete that DataPoint.
2929
/// </summary>
30-
/// <description>
30+
/// <remarks>
3131
/// Left-click an empty location on the spline to add a new DataPoint to the SplineData.
3232
/// Left-click on a DataPoint to move the point along the Spline. Right-click a DataPoint to delete it.
33-
/// </description>
33+
/// </remarks>
3434
/// <param name="spline">The Spline to use to interprete the SplineData.</param>
3535
/// <param name="splineData">The SplineData for which the handles are drawn.</param>
3636
/// <param name="useDefaultValueOnAdd">Either to use default value or closer DataPoint value when adding new DataPoint.</param>
@@ -48,10 +48,10 @@ public static void DataPointHandles<TSpline, TData>(
4848
/// <summary>
4949
/// Creates manipulation handles in the Scene view that can be used to add, move, and remove SplineData's DataPoints along a spline.
5050
/// </summary>
51-
/// <description>
51+
/// <remarks>
5252
/// Left-click an empty location on the spline to add a new DataPoint to the SplineData.
5353
/// Left-click and drag a DataPoint to move the point along the spline. Right-click a DataPoint to delete it.
54-
/// </description>
54+
/// </remarks>
5555
/// <param name="spline">The spline to use to interprete the SplineData.</param>
5656
/// <param name="splineData">The SplineData for which the handles are drawn.</param>
5757
/// <param name="splineID">The ID for the spline.</param>
@@ -112,7 +112,7 @@ static void DataPointAddHandle<TSpline, TData>(
112112
{
113113
case EventType.Layout:
114114
{
115-
if (!Tools.viewToolActive)
115+
if (!SplineHandles.ViewToolActive())
116116
{
117117
var ray = HandleUtility.GUIPointToWorldRay(evt.mousePosition);
118118
SplineUtility.GetNearestPoint(spline, ray, out var pos, out _);
@@ -133,7 +133,7 @@ static void DataPointAddHandle<TSpline, TData>(
133133

134134
case EventType.MouseDown:
135135
if (evt.button == 0
136-
&& !Tools.viewToolActive
136+
&& !SplineHandles.ViewToolActive()
137137
&& HandleUtility.nearestControl == controlID
138138
&& GUIUtility.hotControl == 0)
139139
{
@@ -241,7 +241,7 @@ static void SplineDataHandle<TSpline, TData>(
241241

242242
case EventType.MouseDown:
243243
if (evt.button == 0
244-
&& !Tools.viewToolActive
244+
&& !SplineHandles.ViewToolActive()
245245
&& HandleUtility.nearestControl == controlID
246246
&& GUIUtility.hotControl == 0)
247247
{

Editor/GUI/SplineGUI.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,31 @@ internal static GUIContent TempContent(string label, string tooltip = null, Text
2222

2323
/// <summary>
2424
/// Creates a dropdown to select an index between 0 and the count of <see cref="Splines"/> contained in the
25-
/// provided <param name="container"></param>.
25+
/// provided <paramref name="container"/>.
2626
/// </summary>
2727
/// <param name="container">A <see cref="SplineContainer"/> that determines how many splines are available in
2828
/// the popup selector.</param>
2929
/// <param name="label">The label to use for this property. If null, the property display name is used.</param>
3030
/// <param name="rect">The rectangle on the screen to use for the field.</param>
3131
/// <param name="property">A SerializedProperty that stores an integer value.</param>
32-
/// <exception cref="ArgumentException">An exception is thrown if <param name="property"> is not an integer
33-
/// field.</param></exception>
32+
/// <exception cref="ArgumentException">An exception is thrown if <paramref name="property"/> is not an integer
33+
/// field.</exception>
3434
/// <typeparam name="T">The type implementing <see cref="ISplineContainer"/>.</typeparam>
3535
public static void SplineIndexField<T>(Rect rect, SerializedProperty property, GUIContent label, T container) where T : ISplineContainer
3636
{
3737
SplineIndexField(rect, property, label, container == null ? 0 : container.Splines.Count);
3838
}
3939

4040
/// <summary>
41-
/// Creates a dropdown to select an index between 0 and <param name="splineCount"></param>.
41+
/// Creates a dropdown to select an index between 0 and <paramref name="splineCount"/>.
4242
/// </summary>
4343
/// <param name="rect">The rectangle on the screen to use for the field.</param>
4444
/// <param name="property">A SerializedProperty that stores an integer value.</param>
4545
/// <param name="label">The label to use for this property. If null, the property display name is used.</param>
4646
/// <param name="splineCount">The number of splines available. In most cases, this is the size of
4747
/// <see cref="SplineContainer.Splines"/></param>
48-
/// <exception cref="ArgumentException">An exception is thrown if <param name="property"> is not an integer
49-
/// field.</param></exception>
48+
/// <exception cref="ArgumentException">An exception is thrown if <paramref name="property"/> is not an integer
49+
/// field.</exception>
5050
public static void SplineIndexField(Rect rect, SerializedProperty property, GUIContent label, int splineCount)
5151
{
5252
if (property.propertyType != SerializedPropertyType.Integer)
@@ -57,7 +57,7 @@ public static void SplineIndexField(Rect rect, SerializedProperty property, GUIC
5757
}
5858

5959
/// <summary>
60-
/// Creates a dropdown to select an index between 0 and <param name="splineCount"></param>.
60+
/// Creates a dropdown to select an index between 0 and <paramref name="splineCount"/>.
6161
/// </summary>
6262
/// <param name="label">An optional prefix label.</param>
6363
/// <param name="splineCount">The number of splines available. In most cases, this is the size of
@@ -88,27 +88,27 @@ public static class SplineGUILayout
8888
{
8989
/// <summary>
9090
/// Creates a dropdown to select an index between 0 and the count of <see cref="Splines"/> contained in the
91-
/// provided <param name="container"></param>.
91+
/// provided <paramref name="container"/>.
9292
/// </summary>
9393
/// <param name="container">A <see cref="SplineContainer"/> that determines how many splines are available in
9494
/// the popup selector.</param>
9595
/// <param name="property">A SerializedProperty that stores an integer value.</param>
96-
/// <exception cref="ArgumentException">An exception is thrown if <param name="property"> is not an integer
97-
/// field.</param></exception>
96+
/// <exception cref="ArgumentException">An exception is thrown if <paramref name="property"/> is not an integer
97+
/// field.</exception>
9898
/// <typeparam name="T">The type implementing <see cref="ISplineContainer"/>.</typeparam>
9999
public static void SplineIndexField<T>(SerializedProperty property, T container) where T : ISplineContainer
100100
{
101101
SplineIndexField(property, container == null ? 0 : container.Splines.Count);
102102
}
103103

104104
/// <summary>
105-
/// Creates a dropdown to select an index between 0 and <param name="splineCount"></param>.
105+
/// Creates a dropdown to select an index between 0 and <paramref name="splineCount"/>.
106106
/// </summary>
107107
/// <param name="property">A SerializedProperty that stores an integer value.</param>
108108
/// <param name="splineCount">The number of splines available. In most cases, this is the size of
109109
/// <see cref="SplineContainer.Splines"/></param>
110-
/// <exception cref="ArgumentException">An exception is thrown if <param name="property"> is not an integer
111-
/// field.</param></exception>
110+
/// <exception cref="ArgumentException">An exception is thrown if <paramref name="property"/> is not an integer
111+
/// field.</exception>
112112
public static void SplineIndexField(SerializedProperty property, int splineCount)
113113
{
114114
if (property.propertyType != SerializedPropertyType.Integer)
@@ -119,7 +119,7 @@ public static void SplineIndexField(SerializedProperty property, int splineCount
119119
}
120120

121121
/// <summary>
122-
/// Creates a dropdown to select a spline index relative to <param name="container"></param>.
122+
/// Creates a dropdown to select a spline index relative to <paramref name="container"/>.
123123
/// </summary>
124124
/// <param name="label">An optional prefix label.</param>
125125
/// <param name="index">The current index.</param>
@@ -133,7 +133,7 @@ public static int SplineIndexPopup<T>(string label, int index, T container) wher
133133
}
134134

135135
/// <summary>
136-
/// Creates a dropdown to select an index between 0 and <param name="splineCount"></param>.
136+
/// Creates a dropdown to select an index between 0 and <paramref name="splineCount"/>.
137137
/// </summary>
138138
/// <param name="label">An optional prefix label.</param>
139139
/// <param name="splineCount">The number of splines available. In most cases, this is the size of

Editor/Tools/CreateSplineTool.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,35 @@
44
using Unity.Mathematics;
55
using System.Collections.Generic;
66
using System;
7+
using UnityEditor.Overlays;
78
using Object = UnityEngine.Object;
89

910
namespace UnityEditor.Splines
10-
{
11+
{
12+
[CustomEditor(typeof(CreateSplineTool))]
13+
#if UNITY_2022_1_OR_NEWER
14+
class CreateSplineToolSettings : UnityEditor.Editor, ICreateToolbar
15+
{
16+
public IEnumerable<string> toolbarElements
17+
{
18+
#else
19+
class CreateSplineToolSettings : CreateToolbarBase
20+
{
21+
protected override IEnumerable<string> toolbarElements
22+
{
23+
#endif
24+
get { yield return "Spline Tool Settings/Default Knot Type"; }
25+
}
26+
}
27+
1128
#if UNITY_2023_1_OR_NEWER
1229
[EditorTool("Create Spline", toolPriority = 10)]
1330
#else
1431
[EditorTool("Create Spline")]
1532
#endif
33+
[Icon("Packages/com.unity.splines/Editor/Resources/Icons/KnotPlacementTool.png")]
1634
class CreateSplineTool : KnotPlacementTool
1735
{
18-
public override GUIContent toolbarIcon => PathIcons.createSplineTool;
19-
2036
[NonSerialized]
2137
List<Object> m_Targets = new List<Object>(1);
2238

Editor/Tools/KnotPlacementTool.cs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,10 @@
1111

1212
#if UNITY_2022_1_OR_NEWER
1313
using UnityEditor.Overlays;
14-
15-
#else
16-
using System.Reflection;
17-
using UnityEditor.Toolbars;
18-
using UnityEngine.UIElements;
1914
#endif
2015

2116
namespace UnityEditor.Splines
2217
{
23-
[CustomEditor(typeof(KnotPlacementTool))]
24-
#if UNITY_2022_1_OR_NEWER
25-
class KnotPlacementToolSettings : UnityEditor.Editor, ICreateToolbar
26-
{
27-
public IEnumerable<string> toolbarElements
28-
{
29-
#else
30-
class KnotPlacementToolSettings : CreateToolbarBase
31-
{
32-
protected override IEnumerable<string> toolbarElements
33-
{
34-
#endif
35-
get { yield return "Spline Tool Settings/Default Knot Type"; }
36-
}
37-
}
38-
3918
abstract class KnotPlacementTool : SplineTool
4019
{
4120
// 6f is the threshold used in RectSelection, but felt a little too sensitive when drawing a path.
@@ -280,8 +259,6 @@ public void Dispose()
280259
public override bool gridSnapEnabled => true;
281260
#endif
282261

283-
public override GUIContent toolbarIcon => PathIcons.editSplineTool;
284-
285262
static PlacementData s_PlacementData;
286263

287264
static SplineInfo s_ClosestSpline = default;
@@ -552,6 +529,8 @@ static void KnotPlacementHandle(
552529
switch (evt.GetTypeForControl(controlId))
553530
{
554531
case EventType.Layout:
532+
// Not using SplineHandles.ViewToolActive() here as otherwise it breaks the handles rendering when
533+
// only pressing ALT and moving the mouse in the view.
555534
if (!Tools.viewToolActive)
556535
HandleUtility.AddDefaultControl(controlId);
557536
break;
@@ -632,7 +611,7 @@ static void KnotPlacementHandle(
632611

633612
case EventType.MouseDown:
634613
{
635-
if (evt.button != 0 || Tools.viewToolActive)
614+
if (evt.button != 0 || SplineHandles.ViewToolActive())
636615
break;
637616

638617
if (HandleUtility.nearestControl == controlId)

Editor/Tools/SplineToolContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public override void PopulateMenu(DropdownMenu menu)
144144
/// Invoked for each window where this context is active. The spline context uses this method to implement
145145
/// common functionality for working with splines, ex gizmo drawing and selection.
146146
/// </summary>
147-
/// <param name="window"></param>
147+
/// <param name="window">The window that is displaying this active context.</param>
148148
public override void OnToolGUI(EditorWindow window)
149149
{
150150
UpdateSelectionIfSplineRemoved(m_Splines);

Editor/Utilities/EditorSplineUtility.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ static SelectableKnot AddKnotInternal(SplineInfo splineInfo, float3 worldPositio
288288
var spline = splineInfo.Spline;
289289

290290
if (spline.Closed && spline.Count >= 2)
291-
throw new ArgumentException("Cannot add a point to the extremity of a closed spline", nameof(spline));
291+
Debug.LogWarning("Cannot add a point to the extremity of a closed spline.");
292+
292293

293294
var localToWorld = splineInfo.LocalToWorld;
294295
var mode = GetModeFromPlacementTangent(tangentOut);
@@ -946,7 +947,7 @@ internal static bool Exists(SplineInfo spline)
946947
/// </summary>
947948
/// <param name="type">The <see cref="EmbeddedSplineDataType"/>.</param>
948949
/// <param name="key">A string value used to identify and access a <see cref="SplineData{T}"/>.</param>
949-
/// <param name="container"></param>
950+
/// <param name="container">The <see cref="ISplineContainer"/> that contains the spline.</param>
950951
/// <param name="source">The index of the <see cref="Spline"/> in the <paramref name="container"/> to copy data from.</param>
951952
/// <param name="destination">The index of the <see cref="Spline"/> in the <paramref name="container"/> to copy data to.</param>
952953
/// <returns>True if data was copied, otherwise false.</returns>

Editor/Utilities/PathIcons.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ namespace UnityEditor.Splines
44
{
55
static class PathIcons
66
{
7-
public static GUIContent createSplineTool = EditorGUIUtility.TrIconContent(GetIcon("KnotPlacementTool"), "Create Spline");
8-
public static GUIContent editSplineTool = EditorGUIUtility.TrIconContent(GetIcon("KnotPlacementTool"), "Edit Spline");
97
public static GUIContent splineMoveTool = EditorGUIUtility.TrIconContent("MoveTool", "Spline Move Tool");
108
public static GUIContent splineRotateTool = EditorGUIUtility.TrIconContent("RotateTool", "Spline Rotate Tool");
119
public static GUIContent splineScaleTool = EditorGUIUtility.TrIconContent("ScaleTool", "Spline Scale Tool");

0 commit comments

Comments
 (0)