Merge branch '4.2' into spine-android

This commit is contained in:
Mario Zechner 2024-04-30 09:42:16 +02:00
commit bf281b1c22
16 changed files with 81 additions and 81 deletions

View File

@ -154,6 +154,7 @@
- SkeletonGraphic: Added pre-defined SkeletonGraphic material sets for main workflow parameters in folders `spine-unity/Materials` instead of requiring manual copies: - SkeletonGraphic: Added pre-defined SkeletonGraphic material sets for main workflow parameters in folders `spine-unity/Materials` instead of requiring manual copies:
`SkeletonGraphic-PMATexture` containing materials for premultiplied-alpha texture workflow (`Straight Alpha Texture` disabled) and `SkeletonGraphic-StaightAlphaTexture` containing materials for straight alpha texture workflow (`Straight Alpha Texture` enabled). These directories contain a set of materials with `CanvasGroup Compatible` disabled for usage with `Advanced - PMA Vertex Color` enabled at the component. Each directory also provides a subdirectory `CanvasGroupCompatible` with materials with `CanvasGroup Compatible` enabled for usage with `CanvasGroup` alpha (requiring `Advanced - PMA Vertex Color` disabled at the component). `SkeletonGraphic-PMATexture` containing materials for premultiplied-alpha texture workflow (`Straight Alpha Texture` disabled) and `SkeletonGraphic-StaightAlphaTexture` containing materials for straight alpha texture workflow (`Straight Alpha Texture` enabled). These directories contain a set of materials with `CanvasGroup Compatible` disabled for usage with `Advanced - PMA Vertex Color` enabled at the component. Each directory also provides a subdirectory `CanvasGroupCompatible` with materials with `CanvasGroup Compatible` enabled for usage with `CanvasGroup` alpha (requiring `Advanced - PMA Vertex Color` disabled at the component).
- SkeletonGraphic: Added auto-detect functionality for parameters `Advanced` - `Tint Black`, `CanvasGroup Compatible` and `PMA Vertex Color`. If unsure which settings are correct, hit the `Detect` button next to each parameter, in top to bottom order, or the `Detect Settings` to detect all three. Also added automatic material assignment via a `Detect Material` button in the `Advanced` section and a `Detect` button next to the `Material` property at the top of the component Inspector, as well as next to the `Blend Mode Materials` section when using multiple canvas renderers with blend modes. The suitable material is selected based on these three settings, combined with texture settings (PMA or straight alpha texture settings). If you receive incorrect results, likely your texture settings are incorrectly setup for your PMA or Straight alpha texture export settings. - SkeletonGraphic: Added auto-detect functionality for parameters `Advanced` - `Tint Black`, `CanvasGroup Compatible` and `PMA Vertex Color`. If unsure which settings are correct, hit the `Detect` button next to each parameter, in top to bottom order, or the `Detect Settings` to detect all three. Also added automatic material assignment via a `Detect Material` button in the `Advanced` section and a `Detect` button next to the `Material` property at the top of the component Inspector, as well as next to the `Blend Mode Materials` section when using multiple canvas renderers with blend modes. The suitable material is selected based on these three settings, combined with texture settings (PMA or straight alpha texture settings). If you receive incorrect results, likely your texture settings are incorrectly setup for your PMA or Straight alpha texture export settings.
- `SkeletonRenderTexture` example components now provide a `shaderPasses` parameter to customize which passes are rendered to the `RenderTexture`. It defaults to `-1` for all passes to keep the existing behaviour. You might want to set it to `0` to only render the first pass e.g. to avoid issues when using a URP shader at the original skeleton.
- **Breaking changes** - **Breaking changes**

View File

@ -52,26 +52,24 @@ namespace Spine {
public IkConstraint (IkConstraintData data, Skeleton skeleton) { public IkConstraint (IkConstraintData data, Skeleton skeleton) {
if (data == null) throw new ArgumentNullException("data", "data cannot be null."); if (data == null) throw new ArgumentNullException("data", "data cannot be null.");
this.data = data; this.data = data;
mix = data.mix;
softness = data.softness;
bendDirection = data.bendDirection;
compress = data.compress;
stretch = data.stretch;
bones = new ExposedList<Bone>(data.bones.Count); bones = new ExposedList<Bone>(data.bones.Count);
foreach (BoneData boneData in data.bones) foreach (BoneData boneData in data.bones)
bones.Add(skeleton.bones.Items[boneData.index]); bones.Add(skeleton.bones.Items[boneData.index]);
target = skeleton.bones.Items[data.target.index]; target = skeleton.bones.Items[data.target.index];
mix = data.mix;
softness = data.softness;
bendDirection = data.bendDirection;
compress = data.compress;
stretch = data.stretch;
} }
/// <summary>Copy constructor.</summary> /// <summary>Copy constructor.</summary>
public IkConstraint (IkConstraint constraint) { public IkConstraint (IkConstraint constraint, Skeleton skeleton)
if (constraint == null) throw new ArgumentNullException("constraint", "constraint cannot be null."); : this(constraint.data, skeleton) {
data = constraint.data;
bones = new ExposedList<Bone>(constraint.Bones.Count);
bones.AddRange(constraint.Bones);
target = constraint.target;
mix = constraint.mix; mix = constraint.mix;
softness = constraint.softness; softness = constraint.softness;
bendDirection = constraint.bendDirection; bendDirection = constraint.bendDirection;

View File

@ -64,6 +64,7 @@ namespace Spine {
bones.Add(skeleton.bones.Items[boneData.index]); bones.Add(skeleton.bones.Items[boneData.index]);
target = skeleton.slots.Items[data.target.index]; target = skeleton.slots.Items[data.target.index];
position = data.position; position = data.position;
spacing = data.spacing; spacing = data.spacing;
mixRotate = data.mixRotate; mixRotate = data.mixRotate;
@ -72,12 +73,9 @@ namespace Spine {
} }
/// <summary>Copy constructor.</summary> /// <summary>Copy constructor.</summary>
public PathConstraint (PathConstraint constraint) { public PathConstraint (PathConstraint constraint, Skeleton skeleton)
if (constraint == null) throw new ArgumentNullException("constraint cannot be null."); : this(constraint.data, skeleton) {
data = constraint.data;
bones = new ExposedList<Bone>(constraint.Bones.Count);
bones.AddRange(constraint.Bones);
target = constraint.target;
position = constraint.position; position = constraint.position;
spacing = constraint.spacing; spacing = constraint.spacing;
mixRotate = constraint.mixRotate; mixRotate = constraint.mixRotate;

View File

@ -60,7 +60,9 @@ namespace Spine {
if (skeleton == null) throw new ArgumentNullException("skeleton", "skeleton cannot be null."); if (skeleton == null) throw new ArgumentNullException("skeleton", "skeleton cannot be null.");
this.data = data; this.data = data;
this.skeleton = skeleton; this.skeleton = skeleton;
bone = skeleton.bones.Items[data.bone.index]; bone = skeleton.bones.Items[data.bone.index];
inertia = data.inertia; inertia = data.inertia;
strength = data.strength; strength = data.strength;
damping = data.damping; damping = data.damping;
@ -71,11 +73,9 @@ namespace Spine {
} }
/// <summary>Copy constructor.</summary> /// <summary>Copy constructor.</summary>
public PhysicsConstraint (PhysicsConstraint constraint) { public PhysicsConstraint (PhysicsConstraint constraint, Skeleton skeleton)
if (constraint == null) throw new ArgumentNullException("constraint", "constraint cannot be null."); : this(constraint.data, skeleton) {
data = constraint.data;
skeleton = constraint.skeleton;
bone = constraint.bone;
inertia = constraint.inertia; inertia = constraint.inertia;
strength = constraint.strength; strength = constraint.strength;
damping = constraint.damping; damping = constraint.damping;

View File

@ -187,19 +187,19 @@ namespace Spine {
ikConstraints = new ExposedList<IkConstraint>(skeleton.ikConstraints.Count); ikConstraints = new ExposedList<IkConstraint>(skeleton.ikConstraints.Count);
foreach (IkConstraint ikConstraint in skeleton.ikConstraints) foreach (IkConstraint ikConstraint in skeleton.ikConstraints)
ikConstraints.Add(new IkConstraint(ikConstraint)); ikConstraints.Add(new IkConstraint(ikConstraint, skeleton));
transformConstraints = new ExposedList<TransformConstraint>(skeleton.transformConstraints.Count); transformConstraints = new ExposedList<TransformConstraint>(skeleton.transformConstraints.Count);
foreach (TransformConstraint transformConstraint in skeleton.transformConstraints) foreach (TransformConstraint transformConstraint in skeleton.transformConstraints)
transformConstraints.Add(new TransformConstraint(transformConstraint)); transformConstraints.Add(new TransformConstraint(transformConstraint, skeleton));
pathConstraints = new ExposedList<PathConstraint>(skeleton.pathConstraints.Count); pathConstraints = new ExposedList<PathConstraint>(skeleton.pathConstraints.Count);
foreach (PathConstraint pathConstraint in skeleton.pathConstraints) foreach (PathConstraint pathConstraint in skeleton.pathConstraints)
pathConstraints.Add(new PathConstraint(pathConstraint)); pathConstraints.Add(new PathConstraint(pathConstraint, skeleton));
physicsConstraints = new ExposedList<PhysicsConstraint>(skeleton.physicsConstraints.Count); physicsConstraints = new ExposedList<PhysicsConstraint>(skeleton.physicsConstraints.Count);
foreach (PhysicsConstraint physicsConstraint in skeleton.physicsConstraints) foreach (PhysicsConstraint physicsConstraint in skeleton.physicsConstraints)
physicsConstraints.Add(new PhysicsConstraint(physicsConstraint)); physicsConstraints.Add(new PhysicsConstraint(physicsConstraint, skeleton));
skin = skeleton.skin; skin = skeleton.skin;
r = skeleton.r; r = skeleton.r;
@ -489,7 +489,7 @@ namespace Spine {
public void PhysicsRotate (float x, float y, float degrees) { public void PhysicsRotate (float x, float y, float degrees) {
PhysicsConstraint[] physicsConstraints = this.physicsConstraints.Items; PhysicsConstraint[] physicsConstraints = this.physicsConstraints.Items;
for (int i = 0, n = this.physicsConstraints.Count; i < n; i++) for (int i = 0, n = this.physicsConstraints.Count; i < n; i++)
physicsConstraints[i].Rotate(r, y, degrees); physicsConstraints[i].Rotate(x, y, degrees);
} }
/// <summary>Increments the skeleton's <see cref="time"/>.</summary> /// <summary>Increments the skeleton's <see cref="time"/>.</summary>

View File

@ -51,27 +51,25 @@ namespace Spine {
if (data == null) throw new ArgumentNullException("data", "data cannot be null."); if (data == null) throw new ArgumentNullException("data", "data cannot be null.");
if (skeleton == null) throw new ArgumentNullException("skeleton", "skeleton cannot be null."); if (skeleton == null) throw new ArgumentNullException("skeleton", "skeleton cannot be null.");
this.data = data; this.data = data;
mixRotate = data.mixRotate;
mixX = data.mixX;
mixY = data.mixY;
mixScaleX = data.mixScaleX;
mixScaleY = data.mixScaleY;
mixShearY = data.mixShearY;
bones = new ExposedList<Bone>(); bones = new ExposedList<Bone>();
foreach (BoneData boneData in data.bones) foreach (BoneData boneData in data.bones)
bones.Add(skeleton.bones.Items[boneData.index]); bones.Add(skeleton.bones.Items[boneData.index]);
target = skeleton.bones.Items[data.target.index]; target = skeleton.bones.Items[data.target.index];
mixRotate = data.mixRotate;
mixX = data.mixX;
mixY = data.mixY;
mixScaleX = data.mixScaleX;
mixScaleY = data.mixScaleY;
mixShearY = data.mixShearY;
} }
/// <summary>Copy constructor.</summary> /// <summary>Copy constructor.</summary>
public TransformConstraint (TransformConstraint constraint) { public TransformConstraint (TransformConstraint constraint, Skeleton skeleton)
if (constraint == null) throw new ArgumentNullException("constraint cannot be null."); : this(constraint.data, skeleton) {
data = constraint.data;
bones = new ExposedList<Bone>(constraint.Bones.Count);
bones.AddRange(constraint.Bones);
target = constraint.target;
mixRotate = constraint.mixRotate; mixRotate = constraint.mixRotate;
mixX = constraint.mixX; mixX = constraint.mixX;
mixY = constraint.mixY; mixY = constraint.mixY;

View File

@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.spine-csharp", "name": "com.esotericsoftware.spine.spine-csharp",
"displayName": "spine-csharp Runtime", "displayName": "spine-csharp Runtime",
"description": "This plugin provides the spine-csharp core runtime.", "description": "This plugin provides the spine-csharp core runtime.",
"version": "4.2.19", "version": "4.2.21",
"unity": "2018.3", "unity": "2018.3",
"author": { "author": {
"name": "Esoteric Software", "name": "Esoteric Software",

View File

@ -54,25 +54,24 @@ public class IkConstraint implements Updatable {
if (data == null) throw new IllegalArgumentException("data cannot be null."); if (data == null) throw new IllegalArgumentException("data cannot be null.");
if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null."); if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null.");
this.data = data; this.data = data;
mix = data.mix;
softness = data.softness;
bendDirection = data.bendDirection;
compress = data.compress;
stretch = data.stretch;
bones = new Array(data.bones.size); bones = new Array(data.bones.size);
for (BoneData boneData : data.bones) for (BoneData boneData : data.bones)
bones.add(skeleton.bones.get(boneData.index)); bones.add(skeleton.bones.get(boneData.index));
target = skeleton.bones.get(data.target.index); target = skeleton.bones.get(data.target.index);
mix = data.mix;
softness = data.softness;
bendDirection = data.bendDirection;
compress = data.compress;
stretch = data.stretch;
} }
/** Copy constructor. */ /** Copy constructor. */
public IkConstraint (IkConstraint constraint) { public IkConstraint (IkConstraint constraint, Skeleton skeleton) {
if (constraint == null) throw new IllegalArgumentException("constraint cannot be null."); this(constraint.data, skeleton);
data = constraint.data;
bones = new Array(constraint.bones);
target = constraint.target;
mix = constraint.mix; mix = constraint.mix;
softness = constraint.softness; softness = constraint.softness;
bendDirection = constraint.bendDirection; bendDirection = constraint.bendDirection;

View File

@ -72,6 +72,7 @@ public class PathConstraint implements Updatable {
bones.add(skeleton.bones.get(boneData.index)); bones.add(skeleton.bones.get(boneData.index));
target = skeleton.slots.get(data.target.index); target = skeleton.slots.get(data.target.index);
position = data.position; position = data.position;
spacing = data.spacing; spacing = data.spacing;
mixRotate = data.mixRotate; mixRotate = data.mixRotate;
@ -80,11 +81,9 @@ public class PathConstraint implements Updatable {
} }
/** Copy constructor. */ /** Copy constructor. */
public PathConstraint (PathConstraint constraint) { public PathConstraint (PathConstraint constraint, Skeleton skeleton) {
if (constraint == null) throw new IllegalArgumentException("constraint cannot be null."); this(constraint.data, skeleton);
data = constraint.data;
bones = new Array(constraint.bones);
target = constraint.target;
position = constraint.position; position = constraint.position;
spacing = constraint.spacing; spacing = constraint.spacing;
mixRotate = constraint.mixRotate; mixRotate = constraint.mixRotate;

View File

@ -58,7 +58,9 @@ public class PhysicsConstraint implements Updatable {
if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null."); if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null.");
this.data = data; this.data = data;
this.skeleton = skeleton; this.skeleton = skeleton;
bone = skeleton.bones.get(data.bone.index); bone = skeleton.bones.get(data.bone.index);
inertia = data.inertia; inertia = data.inertia;
strength = data.strength; strength = data.strength;
damping = data.damping; damping = data.damping;
@ -69,11 +71,9 @@ public class PhysicsConstraint implements Updatable {
} }
/** Copy constructor. */ /** Copy constructor. */
public PhysicsConstraint (PhysicsConstraint constraint) { public PhysicsConstraint (PhysicsConstraint constraint, Skeleton skeleton) {
if (constraint == null) throw new IllegalArgumentException("constraint cannot be null."); this(constraint.data, skeleton);
data = constraint.data;
skeleton = constraint.skeleton;
bone = constraint.bone;
inertia = constraint.inertia; inertia = constraint.inertia;
strength = constraint.strength; strength = constraint.strength;
damping = constraint.damping; damping = constraint.damping;

View File

@ -139,19 +139,19 @@ public class Skeleton {
ikConstraints = new Array(skeleton.ikConstraints.size); ikConstraints = new Array(skeleton.ikConstraints.size);
for (IkConstraint ikConstraint : skeleton.ikConstraints) for (IkConstraint ikConstraint : skeleton.ikConstraints)
ikConstraints.add(new IkConstraint(ikConstraint)); ikConstraints.add(new IkConstraint(ikConstraint, skeleton));
transformConstraints = new Array(skeleton.transformConstraints.size); transformConstraints = new Array(skeleton.transformConstraints.size);
for (TransformConstraint transformConstraint : skeleton.transformConstraints) for (TransformConstraint transformConstraint : skeleton.transformConstraints)
transformConstraints.add(new TransformConstraint(transformConstraint)); transformConstraints.add(new TransformConstraint(transformConstraint, skeleton));
pathConstraints = new Array(skeleton.pathConstraints.size); pathConstraints = new Array(skeleton.pathConstraints.size);
for (PathConstraint pathConstraint : skeleton.pathConstraints) for (PathConstraint pathConstraint : skeleton.pathConstraints)
pathConstraints.add(new PathConstraint(pathConstraint)); pathConstraints.add(new PathConstraint(pathConstraint, skeleton));
physicsConstraints = new Array(skeleton.physicsConstraints.size); physicsConstraints = new Array(skeleton.physicsConstraints.size);
for (PhysicsConstraint physicsConstraint : skeleton.physicsConstraints) for (PhysicsConstraint physicsConstraint : skeleton.physicsConstraints)
physicsConstraints.add(new PhysicsConstraint(physicsConstraint)); physicsConstraints.add(new PhysicsConstraint(physicsConstraint, skeleton));
skin = skeleton.skin; skin = skeleton.skin;
color = new Color(skeleton.color); color = new Color(skeleton.color);

View File

@ -53,26 +53,25 @@ public class TransformConstraint implements Updatable {
if (data == null) throw new IllegalArgumentException("data cannot be null."); if (data == null) throw new IllegalArgumentException("data cannot be null.");
if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null."); if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null.");
this.data = data; this.data = data;
mixRotate = data.mixRotate;
mixX = data.mixX;
mixY = data.mixY;
mixScaleX = data.mixScaleX;
mixScaleY = data.mixScaleY;
mixShearY = data.mixShearY;
bones = new Array(data.bones.size); bones = new Array(data.bones.size);
for (BoneData boneData : data.bones) for (BoneData boneData : data.bones)
bones.add(skeleton.bones.get(boneData.index)); bones.add(skeleton.bones.get(boneData.index));
target = skeleton.bones.get(data.target.index); target = skeleton.bones.get(data.target.index);
mixRotate = data.mixRotate;
mixX = data.mixX;
mixY = data.mixY;
mixScaleX = data.mixScaleX;
mixScaleY = data.mixScaleY;
mixShearY = data.mixShearY;
} }
/** Copy constructor. */ /** Copy constructor. */
public TransformConstraint (TransformConstraint constraint) { public TransformConstraint (TransformConstraint constraint, Skeleton skeleton) {
if (constraint == null) throw new IllegalArgumentException("constraint cannot be null."); this(constraint.data, skeleton);
data = constraint.data;
bones = new Array(constraint.bones);
target = constraint.target;
mixRotate = constraint.mixRotate; mixRotate = constraint.mixRotate;
mixX = constraint.mixX; mixX = constraint.mixX;
mixY = constraint.mixY; mixY = constraint.mixY;

View File

@ -195,7 +195,8 @@ namespace Spine.Unity.Examples {
protected void RenderSingleMeshToRenderTexture (Mesh mesh, Material graphicMaterial, Texture texture) { protected void RenderSingleMeshToRenderTexture (Mesh mesh, Material graphicMaterial, Texture texture) {
Material meshRendererMaterial = MeshRendererMaterialForTexture(texture); Material meshRendererMaterial = MeshRendererMaterialForTexture(texture);
commandBuffer.DrawMesh(mesh, transform.localToWorldMatrix, meshRendererMaterial, 0, -1); foreach (int shaderPass in shaderPasses)
commandBuffer.DrawMesh(mesh, transform.localToWorldMatrix, meshRendererMaterial, 0, shaderPass);
Graphics.ExecuteCommandBuffer(commandBuffer); Graphics.ExecuteCommandBuffer(commandBuffer);
} }
@ -204,7 +205,8 @@ namespace Spine.Unity.Examples {
for (int i = 0; i < meshCount; ++i) { for (int i = 0; i < meshCount; ++i) {
Material meshRendererMaterial = MeshRendererMaterialForTexture(textures[i]); Material meshRendererMaterial = MeshRendererMaterialForTexture(textures[i]);
commandBuffer.DrawMesh(meshes[i], transform.localToWorldMatrix, meshRendererMaterial, 0, -1); foreach (int shaderPass in shaderPasses)
commandBuffer.DrawMesh(meshes[i], transform.localToWorldMatrix, meshRendererMaterial, 0, shaderPass);
} }
Graphics.ExecuteCommandBuffer(commandBuffer); Graphics.ExecuteCommandBuffer(commandBuffer);
} }

View File

@ -186,9 +186,11 @@ namespace Spine.Unity.Examples {
meshRenderer.GetPropertyBlock(propertyBlock); meshRenderer.GetPropertyBlock(propertyBlock);
meshRenderer.GetSharedMaterials(materials); meshRenderer.GetSharedMaterials(materials);
for (int i = 0; i < materials.Count; i++) for (int i = 0; i < materials.Count; i++) {
commandBuffer.DrawMesh(meshFilter.sharedMesh, transform.localToWorldMatrix, foreach (int shaderPass in shaderPasses)
materials[i], meshRenderer.subMeshStartIndex + i, -1, propertyBlock); commandBuffer.DrawMesh(meshFilter.sharedMesh, transform.localToWorldMatrix,
materials[i], meshRenderer.subMeshStartIndex + i, shaderPass, propertyBlock);
}
Graphics.ExecuteCommandBuffer(commandBuffer); Graphics.ExecuteCommandBuffer(commandBuffer);
} }

View File

@ -45,6 +45,10 @@ namespace Spine.Unity.Examples {
protected Mesh quadMesh; protected Mesh quadMesh;
public RenderTexture renderTexture; public RenderTexture renderTexture;
public Camera targetCamera; public Camera targetCamera;
[Tooltip("Shader passes to render to the RenderTexture. E.g. set the first element " +
"to -1 to render all shader passes, or set it to 0 to only render the first " +
"shader pass, which may be required when using URP.")]
public int[] shaderPasses = new int[1] { -1 };
protected CommandBuffer commandBuffer; protected CommandBuffer commandBuffer;
protected Vector2Int screenSize; protected Vector2Int screenSize;

View File

@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.spine-unity-examples", "name": "com.esotericsoftware.spine.spine-unity-examples",
"displayName": "spine-unity Runtime Examples", "displayName": "spine-unity Runtime Examples",
"description": "This plugin provides example scenes and scripts for the spine-unity runtime.", "description": "This plugin provides example scenes and scripts for the spine-unity runtime.",
"version": "4.2.27", "version": "4.2.28",
"unity": "2018.3", "unity": "2018.3",
"author": { "author": {
"name": "Esoteric Software", "name": "Esoteric Software",