first commit

This commit is contained in:
lethanhsonvsp
2025-11-17 15:16:36 +07:00
commit a40d0921eb
17012 changed files with 2652386 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
* [About Splines](index.md)
* [Splines upgrade guide](upgrade-guide.md)
* [Create a spline](create-a-spline.md)
* [Manipulate splines](manipulate-splines.md)
* [Reverse the flow of a spline](reverse-spline-flow.md)
* [Join splines](join-knots.md)
* [Knots](knots.md)
* [Link and unlink knots](link-unlink-knots.md)
* [Split knots](split-knots.md)
* [Tangents](tangents.md)
* [Tangent modes](tangent-modes.md)
* [Select a tangent mode](select-tangent-mode.md)
* [Select a default tangent mode](select-default-tangent.md)
* [Animate along a spline](animate.md)
* [Animate a GameObject along a spline](animate-spline.md)
* [Change the alignment of an animated GameObject](animate-alignment.md)
* [Configure the movement of a GameObject](animate-movement.md)
* [Spline Animate component reference](animate-component.md)
* [Extrude a mesh along a spline](extrude.md)
* [Create a 3D mesh along a spline](extrude-mesh.md)
* [Spline Extrude component reference](extrude-component.md)
* [Spline Element Inspector overlay reference](element-inspector.md)
* [Spline component reference](spline-component.md)
* [Spline Instantiate component reference](instantiate-component.md)

View File

@@ -0,0 +1,20 @@
# Change the orientation and alignment of the animated GameObject
Select the orientation and alignment that a GameObject uses when it animates along a spline.
To change the orientation and alignment of the animated GameObject, do the following in the GameObject's **Spline Animate** component:
1. In the **Up Axis** dropdown, select which axis the animated GameObject uses as its up direction. The y-axis is the default up direction.
1. In the **Forward Axis** dropdown, select which axis the animated GameObject uses as its forward direction. The z-axis is the default forward direction.
1. In the **Align To** dropdown, select a space to orient the animated GameObject to:
* Select **None** to set no alignment for the animated GameObject. The GameObject's rotation is unaffected.
* Select **Spline Element** to align animated GameObjects to an interpolated orientation calculated from the rotation of the knots closest to its position.
* Select **Spline Object** to align animated GameObjects to the orientation of the target spline.
* Select **World Space** to align animated items to world space orientation.
## Additional resources
* [Animate a GameObject along a spline](animate-spline.md)
* [Control the animated GameObject's movement](animate-movement.md)
* [Spline Animate component reference](animate-component.md)
* [Use components](xref:UsingComponents)

View File

@@ -0,0 +1,27 @@
# Spline Animate component reference
Use the Spline Animate component to animate the position and rotation of a GameObject along a spline.
| **Property** | **Description** |
| :-------------------- | :------------------------ |
| **Spline** | Select a GameObject that has an attached Spline component you want to animate on. |
| **Up Axis** | Select which axis the animated GameObject uses as its up direction. The y-axis is the default up direction. |
| **Forward Axis** | Select which axis the animated GameObject uses as its forward direction. The z-axis is the default forward direction. |
| **Align To** | Select one of the following spaces to orient animated GameObjects to: </br> <ul><li>**None**: Set no alignment for the animated GameObject. The GameObject's rotation is unaffected. </li><li>**Spline Element**: Align animated GameObjects to an interpolated orientation calculated from the rotation of the knots closest to its position.</li> <li>**Spline Object**: Align animated GameObjects to the orientation of the target spline.</li> <li>**World Space**: Align animated items to world space orientation. </li> |
| **Play On Awake** | Start the animation when the GameObject first loads. |
| **Start Offset** | Set a distance on the target spline to start the GameObject's animation at. The range is 0 through 1. A value of 0 starts the animation at the beginning of the spline and a value of 1 starts the animation at the end of the spline. |
| **Method** | Select the animation method that the animation uses. </br> The **Time** method animates the GameObject along the spline from over a period of time measured in seconds. The **Speed** method animates the GameObject along the spline at a set speed measured in meters per second. |
| **Duration** | Set the period of time that it takes for the GameObject to complete its animation along the spline. </br> This property is visible only when you enable the **Time** method. |
| **Speed** | Set the speed that the GameObject animates along the spline at. </br> This property is visible only when you enable the **Speed** method. |
| **Easing** | Select the easing mode that the animation uses. Easing varies the speed of the animation to make it seem more natural and organic. The following easing modes are available: <ul><li>**None**: Set no easing on the animation. The animation speed is linear. </li><li>**Ease In Only**: The animation starts slowly and then speeds up. </li><li>**Ease Out Only**: The animation slows down at the end of its sequence. </li><li>**Ease In-Out**: The animation starts slowly, speeds up, and then ends slowly. **Ease In-Out** is a combination of **Ease In** and **Ease Out**. </li></ul> |
| **Loop Mode** | Select the loop mode that the animation uses. Loop modes cause the animation to repeat after it finishes. The following loop modes are available: <ul><li>**Once**: Set the animation to play only once. </li><li>**Loop Continuous**: Set the animation to restart from its beginning after it finishes. </li><li>**Ease In Then Continuous**: Set the animation to start slowly and then restart from its beginning after it finishes. If **Ease In Only** looping is set, then the easing applies only to the first animation loop. </li><li>**Ping Pong**: Set the animation to play in reverse after it finishes. The animation plays repeatedly. </li></ul> |
| **Preview** | Play, pause, or reset the animation. |
|**Time** | Select a specific time in the sequence of the animation. |
## Additional resources
* [Animate a GameObject along a spline](animate-spline.md)
* [Control the animated GameObject's movement](animate-movement.md)
* [Change the alignment of an animated GameObject](animate-alignment.md)
* [Use components](xref:UsingComponents)

View File

@@ -0,0 +1,32 @@
# Configure an animated GameObject's movement
Control how an animation begins on a spline, its speed, and the animation method it uses.
To control the movement of an animated GameObject, do the following in the GameObject's **Spline Animate** component:
1. To start the animation when the GameObject first loads, enable **Play On Awake**.
1. To set a distance on the spline to start the GameObject's animation at, enter a value for the **Start Offset** property. The range is 0 through 1. A value of 0 starts the animation at the beginning of the spline and a value of 1 starts the animation at the end of the spline.
1. In the **Method** dropdown, select an animation method:
* Select **Time** to animate the GameObject along the spline over a period of time measured in seconds.
* Select **Speed** to animate the GameObject along the spline at a set speed measured in meters per second.
1. In the **Easing** dropdown, select an easing mode for the animation to use:
* Select **None** to add no easing to the animation. The animation speed is linear.
* Select **Ease In Only** to have the animation start slowly and then speed up.
* Select **Ease Out Only** to have the animation slow down at the end of its sequence.
* Select **Ease In-Out** to have the animation start slowly, speed up, and then end slowly. **Ease In-Out** is a combination of **Ease In** and **Ease Out**.
> [!NOTE]
> Easing varies the speed of the animation to make it seem more natural and organic.
1. In the **Loop Mode** dropdown, select if and how the animation repeats after its initial sequence finishes:
* Select **Once** to play the animation once.
* Select **Loop Continuous** to restart the animation from the beginning after it finishes.
* Select **Ease In Then Continuous** to have the animation start slowly and then restart from its beginning after it finishes. If **Ease In Only** looping is set, then the easing applies only to the first animation loop.
* Select **Ping Pong** to have the animation play in reverse after it finishes. The animation plays repeatedly.
## Additional resources
* [Animate a GameObject along a spline](animate-spline.md)
* [Change the alignment of an animated GameObject](animate-alignment.md)
* [Spline Animate component reference](animate-component.md)
* [Use components](xref:UsingComponents)

View File

@@ -0,0 +1,23 @@
# Animate a GameObject along a spline
Move a GameObject along a spline.
Use the [Spline Animate](animate-component.md) component to define the movement of cameras, characters, or other GameObjects in the Editor.
You must have a GameObject with a **Spline** component attached to it in your scene to select as the target spline for the **Spline Animate** component.
By default, the **Spline Animate** component uses the **Time** method to animate a GameObject with set to complete after 1 second. To change what animation method your GameObject uses and how it moves along its target spline, refer to **[Configure the movement of a GameObject](animate-movement.md)**.
To animate a GameObject along a spline:
1. Add the **Spline Animate** component to a GameObject that you want to animate along a spline.
1. In the **Spline Animate** component, for the **Spline** property, select a GameObject that has an attached Spline component that you want to animate on.
1. To view the animation in the Scene view, select **Play** in the **Spline Animate** component's **Preview** panel.
## Additional resources
* [Control the animated GameObject's movement](animate-movement.md)
* [Change the alignment of an animated GameObject](animate-alignment.md)
* [Spline Animate component reference](animate-component.md)
* [Use components](xref:UsingComponents)

View File

@@ -0,0 +1,13 @@
# Animate along a spline
Move a GameObject along a spline.
To refer to a sample scene that demonstrates how the **Spline Animate** component can animate the position and rotation of a GameObject along a spline, [import the **Animate Component** sample scene](index.md#import-splines-samples).
| **Topic** | **Description** |
| :-------------------- | :----------------------- |
| **[Animate a GameObject along a spline](animate-spline.md)** | Use the Spline Animate component to move a GameObject along a spline. |
| **[Change the alignment of an animated GameObject](animate-alignment.md)** | Specify how a GameObject orients and aligns to the spline it's animated on. |
| **[Configure the movement of a GameObject](animate-movement.md)** | Control how an animation begins on a spline, the speed of the animation, and the animation method it uses. |
| **[Spline Animate component reference](animate-component.md)** | Understand the properties of the Spline Animate component. |

View File

@@ -0,0 +1,62 @@
## Quick Start
Splines are defined as implementing the `ISpline` interface. There are two default implementations: a mutable `Spline` class and an immutable `NativeSpline`.
To see more examples of common API use cases, [import the Splines package samples](https://docs.unity3d.com/Packages/com.unity.splines@latest/index.html?subfolder=/manual/index.html%23import-splines-samples) and review the `Runtime/SplineCommonAPI.cs` class.
Splines are represented in the scene using the `SplineContainer` MonoBehaviour.
```cs
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Splines;
class CreateSplineAtStart : MonoBehaviour
{
void Start()
{
// Add a SplineContainer component to this GameObject.
var container = gameObject.AddComponent<SplineContainer>();
// Create a new Spline on the SplineContainer.
var spline = container.AddSpline();
// Set some knot values.
var knots = new BezierKnot[3];
knots[0] = new BezierKnot(new float3(0f, 0f, 0f));
knots[1] = new BezierKnot(new float3(1f, 1f, 0f));
knots[2] = new BezierKnot(new float3(2f, -1f, 0f));
spline.Knots = knots;
}
}
```
The Splines package provides Editor tools for the `SplineContainer` component and `Spline` objects. Other `ISpline` and `ISplineContainer` derived types cannot be edited by the default tools.
Use `SplineUtility` to extract information from `ISpline` objects. For example, use `SplineUtility` to get a position at some interpolation.
```cs
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Splines;
[RequireComponent(typeof(SplineContainer))]
class EvaluateSpline : MonoBehaviour
{
[SerializeField]
float m_Interpolation = .5f;
[SerializeField]
GameObject m_Prefab;
void Start()
{
Spline spline = GetComponent<SplineContainer>()[0];
SplineUtility.Evaluate(spline, m_Interpolation, out float3 position, out float3 direction, out float3 up);
var rotation = Quaternion.LookRotation(direction, up);
Instantiate(m_Prefab, position, rotation);
}
}
```

View File

@@ -0,0 +1,29 @@
# Create a spline
Splines are paths made up of control points called knots. Segments connect knots to other knots. You can place knots onto the surface of objects or [align them to the grid](https://docs.unity3d.com/Manual/GridSnapping.html). Knots can include tangents which control the curvature of the segment at that knot.
## Create a new spline
To create a spline:
> [!NOTE]
> Before you add a knot to a spline, the spline's default location is 0, 0, 0. After you create the spline's first knot, the spline takes that knot's location.
1. Do one of the following:
* In the **Scene** view, from the **Tools** overlay, select **Create Spline**.
* Go to **GameObject** &gt; **Spline** &gt; **Draw Splines Tool**.
* In the [Hierarchy window](xref:Hierarchy), right-click and select **Spline** &gt; **Draw Splines Tool**.
1. Click in the [Scene view](xref:UsingTheSceneView) to create knots for the spline's path to follow. If you want to add a curve to the knot's segment, click and drag to create a knot with tangents.
> [!TIP]
> When you use the Draw Splines Tool, if you click on the surface of a GameObject, the knot snaps to that surface. Otherwise, the knot snaps to the grid.
1. To exit the **Draw Splines Tool**, select a tool in the **Tools** overlay or press Escape.
## Add to an existing spline container
To add a spline to a GameObject's existing spline container:
1. In the **Scene** view, select your spline GameObject.
1. From the **Tools** overlay, select the **Spline** context.
1. From the **Tools** overlay, select **Create Spline**.
1. Create a new spline. It's added to the existing spline container as a new spline. You can attach it to a knot in the existing spline, or leave it disconnected.

View File

@@ -0,0 +1,28 @@
# Element Inspector overlay reference
Use the Element Inspector overlay to configure knots, tangents, and the flow of a spline.
To access the Element Inspector overlay, select knots or tangents on splines in the Scene view.
| **Property** | **Description** |
| :-------------------- | :-------------------------|
| **Knot position** | Set a knot's position. </br></br> This property is visible only when you select knots. |
| **Knot rotation** | Set a knot's rotation. </br></br> This property is visible only when you select knots. |
| **Linear** | Select the **[Linear tangent mode](tangent-modes.md#linear-tangent-mode)** for a knot's tangents. |
| **Auto** | Select the **[Auto tangent mode](tangent-modes.md#auto-tangent-mode)** for a knot's tangents. |
| **Bezier** | Select the **[Bezier tangent mode](tangent-modes.md#bezier-tangent-mode)** for a knot's tangents. |
| **Bezier** | Select the **Bezier** mode for a knot's tangents if the knot is in [Bezier tangent mode](tangent-modes.md#bezier-tangent-mode). </br> </br> The following Bezier modes are available: <ul><li> [**Mirrored**](tangent-modes.md#mirrored-bezier-mode) </li> <li> [**Continuous**](tangent-modes.md#continuous-bezier-mode) </li> <li> [**Broken**](tangent-modes.md#broken-bezier-mode) </li> </ul> |
| **In** | Set the magnitude and direction of the knot's **In** tangent. The **In** tangent defines the curvature of the segment that enters the knot. </br> </br> This property is visible only when you select knots. |
| **Out**| Set the magnitude and direction of the knot's **Out** tangent. The **Out** tangent defines the curvature of the segment that exits the knot. </br> </br> This property is visible only when you select knots. |
| **Magnitude** | Set the magnitude of a tangent. </br> </br> A tangent's magnitude determines how much that tangent affects the curvature of its respective segment. A high magnitude value increases a tangent's influence on a segment's curvature and a low value decreases it. </br> </br> This property is visible only when you select tangents. |
| **Direction** | Set the direction that a tangent points to from its knot. </br> </br> This property is visible only when you select tangents. |
## Additional resources
- [**Tangent modes**](tangent-modes.md)
- [**Link and unlink knots**](link-unlink-knots.md)
- [**Split knots**](split-knots.md)
- [**Join knots**](join-knots.md)
- [**Reverse the flow of a spline**](reverse-spline-flow.md)

View File

@@ -0,0 +1,58 @@
# Spline Extrude component reference
Use the Spline Extrude component to customize the geometry of the mesh you extrude on a spline.
**Note:** If you add Spline Extrude to a GameObject that already has a mesh, that mesh is replaced with a new one.
## Source Spline Container
Select a GameObject that has an attached Spline component you want to extrude a mesh on.
You can use a Spline as a source for the extruded mesh of one or more GameObjects. Edits you make to the source Spline then update those GameObjects. For example, if you want to create a street with a sidewalk, you can create a Spline for the street, and then use the street Spline as a source for a sidewalk GameObject. Any changes you make to the street layout update the sidewalk to match.
## Shape Extrude
| **Property** | | **Description** |
| --- | --- | --- |
| **Type** > **Circle**| | Create a shape with a round cross-section. |
| | **Circle Settings** > **Sides**| Increase to create a smoother surface. The minimum value is `2`. |
| **Type** > **Square** | | Create a shape with a square cross-section. |
| **Type** > **Road** | | Create a shape with a flat cross-section and a slight lip. |
| **Type** > **Spline Profile** | | Use a different spline as a template for the current spline. |
| | **Spline Profile Settings** > **Template** | Select the spline container you want to use as a template. |
| | **Spline Profile Settings** > **Spline Index** | If the template container has more than one spline, select the spline you want.|
| | **Spline Profile Settings** > **Side Count** | Increase to create a smoother surface. The minimum value is `2`. |
| | **Spline Profile Settings** > **Axis** | Which of the template spline axes to follow when drawing this spline. |
## Geometry
| **Property** | **Description** |
| --- | --- |
| **Auto Refresh Generation** | Allow the mesh to update at runtime if the spline changes. |
| **Frequency** | How many times a second to refresh the mesh. |
| **Radius** | Width of the extrusion, measured from the spline path. |
| **Segments Per Unit** | Increase the value to create smoother curves. |
| **Cap Ends** | Fill the ends of an open-ended mesh. |
| **Flip Normals** | Reveal the inside of the 3D shape. |
## Advanced
| **Property** | **Description** |
| --- | --- |
| **Range** | To extrude only some of the spline, define a range. `0` is the first spline point, and `100` is the last one. |
| **Percentage** | Another way to control the **Range**. |
| **Update Colliders** | If the spline has a collider, update the collider to match the 3D shape as you change the extrusion properties. |
## Mesh Filter and Mesh Renderer components
When you add the Spline Extrude component to a GameObject, the Unity Editor adds two more components that all 3D GameObject need:
* [Mesh Renderer Component](https://docs.unity3d.com/Manual/class-MeshRenderer.html)
* [Mesh Filter Component](https://docs.unity3d.com/Manual/class-MeshFilter.html)
## Additional resources
* [Create a 3D mesh along a spline](extrude-mesh.md)
* [Use components](xref:UsingComponents)

View File

@@ -0,0 +1,16 @@
# Create a 3D mesh along a spline
Use the [Spline Extrude](extrude-component.md) component to extrude a mesh along a spline to create shapes such as tubes, wires, ropes, and noodles.
To create a 3D mesh along a spline:
1. [Create a spline](create-a-spline.md).
1. Add the **Spline Extrude** component to the spline GameObject. This component controls the properties of the extruded mesh. To customize the properties, refer to the [Spline Extrude component reference](extrude-component.md).
1. Adding a **Spline Extrude** component automatically adds a **Mesh Filter** and **Mesh Renderer** component to the GameObject. These components are necessary for all 3D GameObjects. Refer to [Mesh Renderer Component](https://docs.unity3d.com/Manual/class-MeshRenderer.html) and [Mesh Filter Component](https://docs.unity3d.com/Manual/class-MeshFilter.html) for more information.
## Additional resources
* [Create a spline](create-a-spline.md)
* [Spline Extrude component reference](extrude-component.md)
* [Use components](xref:UsingComponents)

View File

@@ -0,0 +1,10 @@
# Extrude a mesh along a spline
Extrude a mesh along a spline to create shapes such as tubes, wires, and roads.
To refer to a sample scene that demonstrates how the Spline Extrude component can extrude a mesh along a spline, [import the **Extrude Spline and Nearest Point** sample scene](index.md#import-splines-samples).
| **Topic** | **Description** |
| :-------------------- | :----------------------- |
| **[Create a 3D mesh along a spline](extrude-mesh.md)** | Use the Spline Extrude component to extrude a mesh along a spline. |
| **[Spline Extrude component reference](extrude-component.md)** | Understand the properties of the Spline Extrude component. |

View File

@@ -0,0 +1,15 @@
apiRules:
- exclude:
uidRegex: Tests$
type: Namespace
- exclude:
uidRegex: Debug$
type: Namespace
- exclude:
hasAttribute:
uid: System.ObsoleteAttribute
type: Member
- exclude:
hasAttribute:
uid: System.ObsoleteAttribute
type: Type

View File

@@ -0,0 +1,60 @@
# Getting started with Splines
## Creating the Asset
To create a spline game object there are three different methods.
In the Unity menu, go to **GameObject** > **Spline** > **New Spline**.
<br/><img src="images/getting-started-create-spline-unity-menu.png" alt="Create Spline, Unity Menu" width="350"/>
In the Hierarchy window. RMB > **Spline** > **New Spline**
<br/><img src="images/getting-started-create-spline-hierarchy.png" alt="Create Spline, Hierarchy window" width="350"/>
In the Inspector window, on a GameObject, **Add Component** > **Spline Container** (Script).
<br/><img src="images/getting-started-create-spline-inspector.png" alt="Create Spline, Inspector window" width="350"/>
For more information, see also [Spline Container](spline-container.md).
## Component Editor Tools
The **Knot Placement**, **Knot Move**, and the **Tangent Move** tools are available in the [Component Editor Tools](https://docs.unity3d.com/Manual/UsingCustomEditorTools.html#ToolModesAccessSceneViewPanel) overlay in the Scene window. The **Knot Placement** tool will be automatically engaged after the spline is created with the Unity menu or the Hierarchy window.
<br/><img src="images/getting-started-component-editor-tools.png" alt="Component editor tools" width="350"/>
### Knot Placement Tool
Use the **Knot Placement** tool to add knots. ![](images/KnotPlacementTool.png "Knot Placement Tool")
When the tool is engaged, you can place knots on a surface, such as, a Terrain object or a mesh face.
<br/><img src="images/getting-started-knot-placement.gif" alt="Point Placement" width="350"/>
Clicking on the first point will close the spline.
<br/><img src="images/getting-started-close-loop.gif" alt="Close Loop" width="350"/>
Placing knots not on a surface will place it on the grid instead.
Use **Ctrl** + **z** to delete the last created knot.
Use the **Esc** key to exit the **Knot Placement** creation.
### Knot Move Tool
Use the **Knot Move** tool to move knots.<img src="images/KnotMoveTool.png" alt="Knot Move Tool"/>
You can then select one or more knots to get a position handle to move them around.
<br/><img src="images/getting-started-knot-tool-move-handle.gif" alt="Knot Move Handle" width="350"/>
Clicking on the spline will create a new knot.
<br/><img src="images/getting-started-knot-tool-move-create.gif" alt="Knot Create" width="350"/>
Selecting a knot and then pressing the delete key will delete the knot.
<br/><img src="images/getting-started-knot-tool-move-delete.gif" alt="Knots Delete" width="350"/>
### Tangent Move Tool
Use the **Tangent Move** tool to move knot tangents. <img src="images/TangentMoveTool.png" alt="Tangent Move Tool"/>
This can tool can only be engaged when in the Inspector window on the Spline Container the Edit Mode Type property is set to **Bezier**.
<br/><img src="images/getting-started-knot-tool-tangent-type.png" alt="Edit Mode Type" width="350"/>
The tangent can be manipulated by moving the tangent handle.
<br/><img src="images/getting-started-knot-tool-tangent-handles.gif" alt="Tangent Movement" width="350"/>
Holding Shift while using a tangent handle will display the radial rotation gizmo.
<br/><img src="images/getting-started-knot-tool-tangent-shift.gif" alt="Tangent Shift Rotation" width="350"/>

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1003 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 810 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

View File

@@ -0,0 +1,32 @@
# About Splines
Work with curves and paths. Use the Splines package to generate objects and behaviors along paths, create trajectories, and draw shapes.
The Splines package contains:
* The tools to create and manipulate splines in the Unity Editor.
* The framework to customize the standard spline editing tools in this package.
* A standard data format and storage model for commonly used splines.
* Samples of implementations that address common spline use cases, such as creating a road, animating a GameObject's position and rotation along a spline, instantiating prefabs along a spline to create environments, and more.
## Supported Unity versions
Splines is supported in Unity version 2022.3 and later.
## Install Splines
Before you can use Splines, you must install the Splines package from the Package Manager.
To install this package, follow the instructions in the [Package Manager documentation](https://docs.unity3d.com/Manual/upm-ui-install.html).
## Import Splines samples
The Splines package contains sample scenes that demonstrate different use cases for splines.
To import these sample scenes, you must install the Splines package.
To import sample scenes from the Splines package:
1. Go to **Window** > **Package Manager** to open the Package Manager.
1. In the Package Manager, select **Splines**.
1. Expand the **Samples** section.
1. Next to **Spline Examples**, select **Import**.

View File

@@ -0,0 +1,27 @@
# Spline Instantiate component reference
Use the Spline Instantiate component to instantiate GameObjects on a spline.
| **Property** | **Description** |
| :-------------------- | :------------------------ |
| **Container** | Select a GameObject that has an attached Spline component you want to instantiate GameObjects or prefabs on. |
| **Items To Instantiate** | Create a list of GameObjects or prefabs you want to instantiate. For each element in the list, select a GameObject or prefab, and set a probability for that item to instantiate on the spline. |
| **Up Axis** | Select the axis instantiated items use as their up direction. The y-axis is the default up direction. |
| **Forward Axis** | Select the axis instantiated items use as their forward direction. The z-axis is the default forward direction. |
| **Align To** | Select the space that instantiated items orient to. </br> The following spaces are available: </br> <ul> <li>**Spline Element**: Align instantiated items to an interpolated orientation calculated from the rotation of the knots closest to where each item instantiates. </li> <li>**Spline Object**: Align the instantiated items to the orientation of the target spline. </li> <li>**World Space**: Align instantiated items to world space orientation. </li> </ul> |
| **Instantiate Method** | Select how to instantiate items on the spline. </br> The following instantiate methods are available: <ul> <li> **Instance Count**: Instantiate a number of items on the target spline. </li> <li> **Spline Distance**: Instantiate items separated by distance intervals measured along the spline. </li> <li>**Linear Distance**: Instantiate items separated by distance intervals measured linearly in world space. </li></ul>|
| **Count** | Set a number or an inclusive random range of items to instantiate. </br> This property is visible only when you select the **Instance Count** instantiate method. |
| **Spacing (Spline)** | Set the distance interval to instantiate items at. The distance is measured along the spline. You can set an exact distance or an inclusive random range of values.</br> This property is visible only when you select the **Spline Distance** instantiate method. |
| **Spacing (Linear)** | Set the distance interval to instantiate items at. The distance is measured linearly in world space. </br> To instantiate as many items that can fit on the spline without overlap, select **Auto**. </br> This property is visible only when you select the **Linear Distance** instantiate method. |
| **Position Offset** | Enable to instantiate items at a position relative to the spline. |
| **Rotation Offset** | Enable to instantiate items with a rotation relative to the original GameObject. |
| **Scale Offset** | Enable to instantiate items with a scale relative to the original GameObject. |
| **Override space** | Enable to apply the offset to a coordinate space you select. If you don't enable **Override space**, the offset applies to the coordinate space you set **Align to** to. </br> This property is visible only when you enable **Position Offset**, **Rotation Offset**, or **Scale Offset**. |
| **X** | Set the offset's x-axis value. You can set an exact value or an inclusive random range of values. </br> This property is visible only when you enable **Position Offset**, **Rotation Offset**, or **Scale Offset**. |
| **Y** | Set the offset's y-axis value. You can set an exact value or an inclusive random range of values. </br> This property is visible only when you enable **Position Offset**, **Rotation Offset**, or **Scale Offset**. |
| **Z** | Set the offset's z-axis value. You can set an exact value or an inclusive random range of values. </br> This property is visible only when you enable **Position Offset**, **Rotation Offset**, or **Scale Offset**. |
| **Auto Refresh Generation** | Enable the automatic regeneration of instantiated items when you change the spline or its instantiation values. |
| **Randomize** | Regenerate all values set to random ranges, and then instantiate items again. |
| **Regenerate** | Instantiate items on the spline again. |
| **Clear** | Remove all instantiated items from the spline. |

View File

@@ -0,0 +1,14 @@
# Join splines
Join knots to connect the ends of two splines to each other.
When you join two knots, the new, joined knot takes the position of the active knot. The active knot is the last knot you selected. To join knots, both knots must each have only one segment and be part of different splines attached to the same Spline component.
If you join the knots of two splines that flow in different directions, the new spline takes the direction of the active knot.
To join two splines:
1. [!include[select-spline](.\\snippets\\select-spline.md)]
1. [!include[set-spline-context](.\\snippets\\set-spline-context.md)]
1. Select two knots that are from different splines and have only one segment each.
1. In the Scene view, right-click to open the context menu.
1. In the Scene view context menu, and select **Join Knots**.

View File

@@ -0,0 +1,11 @@
# Knots
Knots are connected control points that make up splines. Knots connect to each other with segments. A knot can have a tangent that controls the curvature of the segments that knot connects to.
Use knots to change the shape of a spline. For more information, refer to [Manipulate splines](manipulate-splines.md).
| **Topic** | **Description** |
| :-------------------- | :----------------------- |
| [**Link and unlink knots**](link-unlink-knots.md) | Set knots to the same position and link them. When a linked knot moves, all the knots it links to also move.|
| [**Split knots**](split-knots.md)| Divide a knot with two segments into two knots.|

View File

@@ -0,0 +1,50 @@
# Link and unlink knots
You can link knots from splines attached to the same Spline component. Linked knots share a position. When you move a knot, its linked knots also move.
Use linked knots to create a spline with branched paths. For example, you can create a spline that represents the following:
- A road with merging lanes
- A river with tributaries
- A diverging sets of mountain paths.
You can link knots in the Scene view context menu or with the **Draw Splines Tool** in the [Scene view](xref:UsingTheSceneView). Use the Scene view context menu to unlink knots.
> [!NOTE]
> You can link more than two knots to each other. If you link knots that are already linked to other knots, all the knots link to each other.
## Link knots with the Draw Splines Tool
To create a linked knot with the **Draw Splines Tool**:
1. [!include[select-spline](.\\snippets\\select-spline.md)]
1. [!include[set-spline-context](.\\snippets\\set-spline-context.md)]
1. In the Tools overlay, select the **Draw Splines Tool**.
1. Select a knot that has two segments to create a knot that links to it.
The new knot is the first knot of a new spline.
> [!NOTE]
> If you use the **Draw Splines Tool** to create a knot on a linked knot, then that new knot is added to the existing link.
## Link knots in the Scene view context menu
To link knots in the Scene view context menu:
1. [!include[select-spline](.\\snippets\\select-spline.md)]
1. [!include[set-spline-context](.\\snippets\\set-spline-context.md)]
1. Select at least two knots.
1. In the Scene view, right-click to open the context menu.
1. In the Scene view context menu, select **Link Knots**.
## Unlink knots
To unlink knots:
1. [!include[select-spline](.\\snippets\\select-spline.md)]
1. [!include[set-spline-context](.\\snippets\\set-spline-context.md)]
1. Select a linked knot.
1. In the Scene view, right-click to open the context menu.
1. In the Scene view context menu, select **Unlink Knots**.
## Additional resources
* [Knots](knots.md)

View File

@@ -0,0 +1,44 @@
# Manipulate splines
You can move, rotate, and scale splines like other GameObjects. Refer to [Positioning GameObjects](xref:PositioningGameObjects) in the Unity User Manual to learn more.
Knots and tangents determine a spline's path and shape. To change a spline's path or shape, manipulate a spline's knots and tangents.
## Select knots or tangents in the Scene view
Activate the **Spline** tool context to use the Move, Rotate, and Scale tools on knots or tangents in the Scene view. Once your active tool context is **Spline**, a spline's knots and tangents are visible and you can select them in the Scene view. When your active tool context is **Spline**, you can't select GameObjects that aren't splines in the Scene view.
To select the knots or tangents of a spline in the Scene view:
1. [!include[select-spline](.\\snippets\\select-spline.md)]
1. [!include[set-spline-context](.\\snippets\\set-spline-context.md)]
1. In the Scene view, select a knot or tangent.
1. To select multiple knots and tangents, do one of the following:
* Click and drag to draw a box over multiple knots and tangents.
* Hold Shift and then click the knots or tangents you want to select.
## Toggle tool handle positions with splines
You can toggle tool handle positions for knots and tangents like you would with other GameObjects. When you have multiple knots and tangents selected, a tool's handle position affects the behavior of some transform tools, such as the **Rotate** and **Scale** tools.
Use the tool handle position toggles in the [Tool Settings Overlay](https://docs.unity3d.com/Documentation/Manual/overlays.html) to select the following tool handle positions for knots and tangents:
* **Pivot**: Set the tool handle at the active element's pivot point. The active element is the last item you selected. If you select multiple knots or tangents:
* The **Rotate** tool rotates the active element around its own pivot point and then applies that same rotation to the other knots in the selection.
* The **Scale** tool scales the knots and tangents from each element's own pivot point.
* **Center**: Set the tool handle at the center of a selection. If you select multiple knots or tangents:
* The **Rotate** tool rotates the knots or tangents around a handle centered between the selected elements.
* The **Scale** tool scales the knots or tangents from a handle centered between the selected elements.
## Toggle tool handle rotation with splines
You can toggle tool handle rotations for knots and tangents like you would with other GameObjects. Besides the default tool handle rotation settings, **Global** and **Local**, knots and tangents have the **Parent** and **Element** handle rotations. When you have multiple knots and tangents selected, a tool's handle rotation setting affects the behavior of some transform tools, such as the **Rotate** and **Scale** tools.
Use the tool handle rotation position toggles in the [Tool Settings Overlay](xref:overlays) to select the following tool handle rotation positions for knots and tangents:
* **Global**: Clamp a spline element to world space orientation.
* **Local**: Keep a spline element's rotation relative to its parent spline.
* **Parent**: Set spline elements to take their parent element's orientation. For example, a tangent with its tool handle rotation set to **Parent** keeps its orientation relative to its parent knot. A knot with its tool handle rotation set to **Parent** keeps its orientation relative to its parent spline GameObject.
* **Element**: Set the tool handle to the active element's orientation.

View File

@@ -0,0 +1,24 @@
# Reverse the flow of a spline
Reverse the flow direction of a spline.
Each spline has a flow direction that moves from its first knot to its last knot. Arrows on the segments and knots of a spline indicate the flow direction of the spline.
If you reverse the flow of a spline, you create a spline that mirrors the original spline. The following occurs:
* The knot indices of the spline reverse. For example, the first knot of the original spline becomes the last knot of the reversed spline.
* For knots in the [Bezier tangent mode](tangent-modes#bezier-tangent-mode), the In tangent becomes the Out tangent and the Out tangent becomes the In tangent.
To reverse the flow of a spline:
1. [!include[select-spline](.\\snippets\\select-spline.md)]
1. [!include[set-spline-context](.\\snippets\\set-spline-context.md)]
1. Select a knot on the spline.
1. In the Scene view, right-click to open the context menu.
1. In the Scene view context menu, select **Reverse Spline Flow**.
## Additional resources
* [Knots](knots.md)
* [Tangent modes](tangent-modes.md)

View File

@@ -0,0 +1,11 @@
# Select a default tangent mode
You can select a [tangent mode](tangent-modes.md) for the **Draw Splines Tool** to use by default.
In each tangent mode, you can click and drag to create a knot in the **[Mirrored Bezier mode](tangent-modes.md#mirrored-bezier-mode)**.
Select a default [tangent mode](tangent-modes.md) for the **Draw Splines Tool**:
1. [!include[select-spline](.\\snippets\\select-spline.md)]
1. [!include[set-spline-context](.\\snippets\\set-spline-context.md)]
1. In the Tools overlay, select the **Draw Splines Tool**.
1. In the Tools Settings overlay, select **[Auto](tangent-modes.md#auto-tangent-mode)** or **[Linear](tangent-modes.md#linear-tangent-mode)** from the dropdown menu.

View File

@@ -0,0 +1,9 @@
# Select tangent mode
You can select a [tangent mode](tangent-modes.md) for a knot. The tangent mode determines the curve between selected knots or all the knots on a selected spline.
To select a tangent mode:
1. [!include[select-spline](.\\snippets\\select-spline.md)]
1. [!include[set-spline-context](.\\snippets\\set-spline-context.md)]
1. Select the knots or tangents that you want to select a tangent mode for.
1. In the **Element Inspector** overlay, select a [tangent mode](tangent-modes.md).

View File

@@ -0,0 +1,5 @@
---
title: select-spline
---
In the [Hierarchy window](xref:Hierarchy) or [Scene view](xref:UsingTheSceneView), select a GameObject with a Spline component.

View File

@@ -0,0 +1,5 @@
---
title: set-spline-context
---
In the [Tools overlay](xref:overlays), set the tool context to **Spline**.

View File

@@ -0,0 +1,13 @@
# Spline component reference
The Spline component attaches splines to a GameObject. The Spline component can contain an unlimited number of splines.
You can use the Spline component to manipulate the transform values of a spline's knots and tangents.
| **Property** | **Description** |
| :-------------------- | :-------------------------|
| **Spline** | Contains the knots that make up a spline. |
| **Closed** | Create a segment between the first and last knots of this spline.|
| **Knot** | Set the position, rotation, and tangents of a knot.|

View File

@@ -0,0 +1,16 @@
# Split knots
Split knots to separate a spline into two splines.
You can only split a knot that has two segments. Split knots each have one segment.
> [!NOTE]
> If you split a knot on a closed spline, the knot where the closure is becomes two [linked knots](link-unlink-knots.md) in two separate splines. These linked knots keep the shape of the original spline.
To split a knot:
1. [!include[select-spline](.\\snippets\\select-spline.md)]
1. [!include[set-spline-context](.\\snippets\\set-spline-context.md)]
1. Select a knot with two segments.
1. In the Scene view, right-click to open the context menu.
1. In the Scene view context menu, select **Split Knot**.

View File

@@ -0,0 +1,69 @@
# Tangent modes
You can [select a tangent mode](select-tangent-mode.md) for knots that determines how their tangents are calculated.
Knots support the following tangent modes:
* [Linear](#linear-tangent-mode)
* [Auto](#auto-tangent-mode)
* [Bezier](#bezier-tangent-mode)
## Linear tangent mode
Use the **Linear** tangent mode to create a spline with straight lines or sharp corners.
The **Linear** tangent mode sets a knot's tangents to a length of `0` so that they point directly at the preceding and following knots.
In **Linear** mode, tangents are automatically computed and cannot be directly manipulated in the Scene view.
## Auto tangent mode
Use the **Auto** mode to create splines with smooth curves.
The **Auto** tangent mode calculates a knot's tangents based on the positions of its preceding and following knots. When you create a new knot on a spline in **Auto** mode, the preceding knot's segment curve adjusts according to the position of the new knot. If you rotate a knot in **Auto** mode, its tangents do not rotate with it.
In **Auto** mode, tangents are automatically computed and cannot be directly manipulated in the Scene view.
> [!NOTE]
> The **Auto** tangent mode creates Catmull-Rom splines.
## Bezier tangent mode
Use the **Bezier** tangent mode to create splines with tangents you can directly manipulate and modify in the Scene view.
You can select the following **Bezier** modes for knots in the **Bezier** tangent mode:
* [**Mirrored**](#mirrored-bezier-mode)
* [**Continuous**](#continuous-bezier-mode)
* [**Broken**](#broken-bezier-moode)
### Mirrored Bezier mode
Set a knot's tangents to point in opposite directions and have equal lengths.
A knot in **Mirrored** mode always points to its **Out** tangent. If you move tangents in **Mirrored** mode, the parent knot rotates to point to its **Out** tangent. If you rotate a knot in **Mirrored** mode, its tangents rotate with it.
> [!NOTE]
> For splines with non-uniform scaling, a knot in **Mirrored** mode might not point to its **Out** tangent. Non-uniform scaling is when the Scale in a Transform has different values for the x-axis, y-axis, and z-axis. For example, a spline with Scale values of (1 , 5, 10) has non-uniform scaling.
If you select a tangent and set it to **Mirrored** mode, it mirrors the opposite tangent. For example, if you set an Out tangent to **Mirrored**, the In tangent's length and direction change, but the Out tangent's length and direction do not change.
### Continuous Bezier mode
Align a knot's tangents so they always point in opposite directions. The length of tangents in **Continuous** mode are independent of each other and you can set them to different values.
A knot in **Continuous** mode always points to its **Out** tangent. If you move tangents in **Continuous** mode, the parent knot rotates to point to its **Out** tangent. If you rotate a knot in **Continuous** mode, its tangents rotate with it.
> [!NOTE]
> For splines with non-uniform scaling, a knot in **Continuous** mode might not point to its **Out** tangent. Non-uniform scaling is when the Scale in a Transform has different values for the x-axis, y-axis, and z-axis. For example, a spline with Scale values of (1 , 5, 10) has non-uniform scaling.
If you select a tangent and set it to **Continuous** mode, it aligns with the opposite tangent. For example, if you set an Out tangent to **Continuous**, the In tangent's direction changes, but the Out tangent's direction does not change.
### Broken Bezier mode
Dissociate a knot's tangents from each other. Use the **Broken** mode to directly manipulate each tangent's length and direction.
If you rotate a knot in **Broken** mode, its tangents rotate with it.

View File

@@ -0,0 +1,13 @@
# Tangents
Tangents define the in and out curvature of a knot's segments.
Tangents have a length and direction. Length determines how much that tangent affects the curvature of its respective segment. A large length value increases a tangent's influence on a segment's curvature and a small length decreases it. Direction determines where the tangent points to from its parent knot.
A spline or knot's tangent mode determines how their tangents are calculated. If a knot is in the **Bezier** tangent mode, then you can directly manipulate its tangents in the Scene view. If a knot is in the [Auto](tangent-modes.md#auto-tangent-mode) or [Linear](tangent-modes.md#linear-tangent-mode) tangent mode, its tangents are calculated automatically.
| **Topic** | **Description** |
| :-------------------- |:---------------------------------------------------------------------|
| **[Tangent modes](tangent-modes.md)** | Understand the different tangent modes. |
| **[Select a tangent mode](select-tangent-mode.md)**| Select a tangent mode for a knot. |
| **[Select a default tangent mode](select-default-tangent.md)**| Select the default tangent mode that the **Draw Splines Tool** uses. |

View File

@@ -0,0 +1,3 @@
# Splines upgrade guide
This is a new package release. In future package versions, this page will display a list of the actions you need to take to upgrade your project to that version.

View File

@@ -0,0 +1,3 @@
# What's new
This is a new package release. In future package versions, this page will display a summary of updates and changes for that version.