Class SpriteSkin
Deforms the Sprite that is currently assigned to the SpriteRenderer in the same GameObject.
Inherited Members
Namespace: UnityEngine.U2D.Animation
Syntax
[Preserve]
[ExecuteInEditMode]
[DefaultExecutionOrder(10)]
[DisallowMultipleComponent]
[RequireComponent(typeof(SpriteRenderer))]
[AddComponentMenu("2D Animation/Sprite Skin")]
[Icon("Packages/com.unity.2d.animation/Editor/Assets/ComponentIcons/Animation.SpriteSkin.png")]
[MovedFrom("UnityEngine.U2D.Experimental.Animation")]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.2d.animation@latest/index.html?subfolder=/manual/SpriteSkin.html")]
public sealed class SpriteSkin : MonoBehaviour, IPreviewable, ISerializationCallbackReceiver
Properties
alwaysUpdate
Determines if the SpriteSkin executes even if the associated SpriteRenderer has been culled from view.
Declaration
public bool alwaysUpdate { get; set; }
Property Value
| Type | Description |
|---|---|
| Boolean |
boneTransforms
Returns the Transform Components that are used for deformation. Do not modify elements of the returned array.
Declaration
public Transform[] boneTransforms { get; }
Property Value
| Type | Description |
|---|---|
| Transform[] | An array of Transform Components. |
forceCpuDeformation
Always run a deformation pass on the CPU.
If GPU deformation is enabled, enabling forceCpuDeformation will cause the deformation to run twice, one time on the CPU and one time on the GPU.
Declaration
public bool forceCpuDeformation { get; set; }
Property Value
| Type | Description |
|---|---|
| Boolean |
rootBone
Returns the Transform Component that represents the root bone for deformation.
Declaration
public Transform rootBone { get; }
Property Value
| Type | Description |
|---|---|
| Transform | A Transform Component. |
Methods
GetDeformedVertexPositionData()
Gets an enumerable to iterate through all deformed vertex positions of this SpriteSkin.
Declaration
public IEnumerable<Vector3> GetDeformedVertexPositionData()
Returns
| Type | Description |
|---|---|
| IEnumerable<Vector3> | Returns an IEnumerable to deformed vertex positions. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when there is no vertex positions or deformed vertices. HasCurrentDeformedVertices can be used to verify if there are any deformed vertices available. |
GetDeformedVertexTangentData()
Gets an enumerable to iterate through all deformed vertex tangents of this SpriteSkin.
Declaration
public IEnumerable<Vector4> GetDeformedVertexTangentData()
Returns
| Type | Description |
|---|---|
| IEnumerable<Vector4> | Returns an IEnumerable to deformed vertex tangents. |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when there is no vertex tangents or deformed vertices. HasCurrentDeformedVertices can be used to verify if there are any deformed vertices available. |
HasCurrentDeformedVertices()
Returns whether this SpriteSkin has currently deformed vertices.
Declaration
public bool HasCurrentDeformedVertices()
Returns
| Type | Description |
|---|---|
| Boolean | Returns true if this SpriteSkin has currently deformed vertices. Returns false otherwise. |
OnAfterDeserialize()
Called after object is deserialized.
Declaration
public void OnAfterDeserialize()
Implements
OnBeforeSerialize()
Called before object is serialized.
Declaration
public void OnBeforeSerialize()
Implements
ResetBindPose()
Resets the bone transforms to the bind pose.
Declaration
public bool ResetBindPose()
Returns
| Type | Description |
|---|---|
| Boolean | True if successful. |
SetBoneTransforms(Transform[])
Sets the Transform Components that are used for deformation.
Declaration
public SpriteSkinState SetBoneTransforms(Transform[] boneTransformsArray)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform[] | boneTransformsArray | Array of new bone Transforms. |
Returns
| Type | Description |
|---|---|
| SpriteSkinState | The state of the Sprite Skin. |
SetRootBone(Transform)
Sets the Transform Component that represents the root bone for deformation.
Declaration
public SpriteSkinState SetRootBone(Transform rootBoneTransform)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | rootBoneTransform | Root bone Transform Component. |
Returns
| Type | Description |
|---|---|
| SpriteSkinState | The state of the Sprite Skin. |