mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +08:00
[unity] Automatically applying Transform position changes to skeleton physics constraints at skeleton components. See commit b5d1aea.
This commit is contained in:
parent
b5d1aea3c5
commit
09e1436504
@ -243,6 +243,15 @@ namespace Spine.Unity {
|
||||
state.Update(deltaTime);
|
||||
skeleton.Update(deltaTime);
|
||||
|
||||
if (Application.isPlaying) {
|
||||
Vector2 position = new Vector2(transform.position.x, transform.position.z);
|
||||
Vector2 positionDelta = position - lastPosition;
|
||||
positionDelta.x /= transform.lossyScale.x;
|
||||
positionDelta.y /= transform.lossyScale.z;
|
||||
skeleton.PhysicsTranslate(positionDelta.x, positionDelta.y);
|
||||
lastPosition = position;
|
||||
}
|
||||
|
||||
if (updateMode == UpdateMode.OnlyAnimationStatus) {
|
||||
state.ApplyEventTimelinesOnly(skeleton, issueEvents: false);
|
||||
return;
|
||||
|
||||
@ -381,6 +381,15 @@ namespace Spine.Unity {
|
||||
state.Update(deltaTime);
|
||||
skeleton.Update(deltaTime);
|
||||
|
||||
if (Application.isPlaying) {
|
||||
Vector2 position = new Vector2(transform.position.x, transform.position.z);
|
||||
Vector2 positionDelta = (position - lastPosition) / meshScale;
|
||||
positionDelta.x /= transform.lossyScale.x;
|
||||
positionDelta.y /= transform.lossyScale.z;
|
||||
skeleton.PhysicsTranslate(positionDelta.x, positionDelta.y);
|
||||
lastPosition = position;
|
||||
}
|
||||
|
||||
if (updateMode == UpdateMode.OnlyAnimationStatus) {
|
||||
state.ApplyEventTimelinesOnly(skeleton, issueEvents: false);
|
||||
return;
|
||||
@ -474,6 +483,7 @@ namespace Spine.Unity {
|
||||
|
||||
#region API
|
||||
protected Skeleton skeleton;
|
||||
|
||||
public Skeleton Skeleton {
|
||||
get {
|
||||
Initialize(false);
|
||||
@ -518,6 +528,9 @@ namespace Spine.Unity {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Used for applying Transform translation to skeleton physics.</summary>
|
||||
protected Vector2 lastPosition;
|
||||
|
||||
[SerializeField] protected Spine.Unity.MeshGenerator meshGenerator = new MeshGenerator();
|
||||
public Spine.Unity.MeshGenerator MeshGenerator { get { return this.meshGenerator; } }
|
||||
DoubleBuffered<Spine.Unity.MeshRendererBuffers.SmartMesh> meshBuffers;
|
||||
|
||||
@ -125,6 +125,16 @@ namespace Spine.Unity {
|
||||
return;
|
||||
|
||||
skeleton.Update(deltaTime);
|
||||
|
||||
if (Application.isPlaying) {
|
||||
Vector2 position = new Vector2(transform.position.x, transform.position.z);
|
||||
Vector2 positionDelta = position - lastPosition;
|
||||
positionDelta.x /= transform.lossyScale.x;
|
||||
positionDelta.y /= transform.lossyScale.z;
|
||||
skeleton.PhysicsTranslate(positionDelta.x, positionDelta.y);
|
||||
lastPosition = position;
|
||||
}
|
||||
|
||||
ApplyAnimation();
|
||||
}
|
||||
|
||||
|
||||
@ -286,6 +286,9 @@ namespace Spine.Unity {
|
||||
return skeleton;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Used for applying Transform translation to skeleton physics.</summary>
|
||||
protected Vector2 lastPosition;
|
||||
#endregion
|
||||
|
||||
public delegate void SkeletonRendererDelegate (SkeletonRenderer skeletonRenderer);
|
||||
@ -424,6 +427,7 @@ namespace Spine.Unity {
|
||||
UpdateMode updateModeSaved = updateMode;
|
||||
updateMode = UpdateMode.FullUpdate;
|
||||
UpdateWorldTransform(Skeleton.Physics.Update);
|
||||
lastPosition = this.transform.position;
|
||||
LateUpdate();
|
||||
updateMode = updateModeSaved;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name": "com.esotericsoftware.spine.spine-unity",
|
||||
"displayName": "spine-unity Runtime",
|
||||
"description": "This plugin provides the spine-unity runtime core.",
|
||||
"version": "4.2.41",
|
||||
"version": "4.2.42",
|
||||
"unity": "2018.3",
|
||||
"author": {
|
||||
"name": "Esoteric Software",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user