[unity] PhysicsConstraints: Made applyRotationToPhysics and applyTranslationToPhysics protected, added getter/setter automatically resetting last position (see commit 4266c72).

This commit is contained in:
Harald Csaszar 2024-02-06 16:20:54 +01:00
parent 2a42f1a160
commit c46ae017fd
2 changed files with 48 additions and 4 deletions

View File

@ -568,9 +568,9 @@ namespace Spine.Unity {
} }
/// <summary>When enabled, Transform translation is applied to skeleton PhysicsConstraints.</summary> /// <summary>When enabled, Transform translation is applied to skeleton PhysicsConstraints.</summary>
public bool applyTranslationToPhysics = true; [SerializeField] protected bool applyTranslationToPhysics = true;
/// <summary>When enabled, Transform rotation is applied to skeleton PhysicsConstraints.</summary> /// <summary>When enabled, Transform rotation is applied to skeleton PhysicsConstraints.</summary>
public bool applyRotationToPhysics = true; [SerializeField] protected bool applyRotationToPhysics = true;
/// <summary>Reference transform relative to which physics movement will be calculated, or null to use world location.</summary> /// <summary>Reference transform relative to which physics movement will be calculated, or null to use world location.</summary>
[SerializeField] protected Transform physicsMovementRelativeTo = null; [SerializeField] protected Transform physicsMovementRelativeTo = null;
@ -579,6 +579,28 @@ namespace Spine.Unity {
/// <summary>Used for applying Transform rotation to skeleton PhysicsConstraints.</summary> /// <summary>Used for applying Transform rotation to skeleton PhysicsConstraints.</summary>
protected float lastRotation; protected float lastRotation;
/// <summary>When enabled, Transform translation is applied to skeleton PhysicsConstraints.</summary>
public bool ApplyTranslationToPhysics {
get {
return applyTranslationToPhysics;
}
set {
if (value && !applyTranslationToPhysics) ResetLastPosition();
applyTranslationToPhysics = value;
}
}
/// <summary>When enabled, Transform rotation is applied to skeleton PhysicsConstraints.</summary>
public bool ApplyRotationToPhysics {
get {
return applyRotationToPhysics;
}
set {
if (value && !applyRotationToPhysics) ResetLastRotation();
applyRotationToPhysics = value;
}
}
/// <summary>Reference transform relative to which physics movement will be calculated, or null to use world location.</summary> /// <summary>Reference transform relative to which physics movement will be calculated, or null to use world location.</summary>
public Transform PhysicsMovementRelativeTo { public Transform PhysicsMovementRelativeTo {
get { get {

View File

@ -290,9 +290,9 @@ namespace Spine.Unity {
#region Physics #region Physics
/// <summary>When enabled, Transform translation is applied to skeleton PhysicsConstraints.</summary> /// <summary>When enabled, Transform translation is applied to skeleton PhysicsConstraints.</summary>
public bool applyTranslationToPhysics = true; [SerializeField] protected bool applyTranslationToPhysics = true;
/// <summary>When enabled, Transform rotation is applied to skeleton PhysicsConstraints.</summary> /// <summary>When enabled, Transform rotation is applied to skeleton PhysicsConstraints.</summary>
public bool applyRotationToPhysics = true; [SerializeField] protected bool applyRotationToPhysics = true;
/// <summary>Reference transform relative to which physics movement will be calculated, or null to use world location.</summary> /// <summary>Reference transform relative to which physics movement will be calculated, or null to use world location.</summary>
[SerializeField] protected Transform physicsMovementRelativeTo = null; [SerializeField] protected Transform physicsMovementRelativeTo = null;
@ -301,6 +301,28 @@ namespace Spine.Unity {
/// <summary>Used for applying Transform rotation to skeleton PhysicsConstraints.</summary> /// <summary>Used for applying Transform rotation to skeleton PhysicsConstraints.</summary>
protected float lastRotation; protected float lastRotation;
/// <summary>When enabled, Transform translation is applied to skeleton PhysicsConstraints.</summary>
public bool ApplyTranslationToPhysics {
get {
return applyTranslationToPhysics;
}
set {
if (value && !applyTranslationToPhysics) ResetLastPosition();
applyTranslationToPhysics = value;
}
}
/// <summary>When enabled, Transform rotation is applied to skeleton PhysicsConstraints.</summary>
public bool ApplyRotationToPhysics {
get {
return applyRotationToPhysics;
}
set {
if (value && !applyRotationToPhysics) ResetLastRotation();
applyRotationToPhysics = value;
}
}
/// <summary>Reference transform relative to which physics movement will be calculated, or null to use world location.</summary> /// <summary>Reference transform relative to which physics movement will be calculated, or null to use world location.</summary>
public Transform PhysicsMovementRelativeTo { public Transform PhysicsMovementRelativeTo {
get { get {