[unity] Backport of 1af0805: Fixed deprecation warnings on Unity 6000.3. See #3013.

This commit is contained in:
Harald Csaszar 2026-01-23 21:38:05 +01:00
parent 43e530611d
commit 42a0ab846a
8 changed files with 64 additions and 4 deletions

View File

@ -27,6 +27,10 @@
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#if UNITY_2023_1_OR_NEWER
#define USE_COLLIDER_COMPOSITE_OPERATION
#endif
using Spine.Unity;
using System.Collections;
using UnityEngine;
@ -65,7 +69,7 @@ namespace Spine.Unity.Examples {
void Launch () {
RemoveRigidbody();
ragdoll.Apply();
ragdoll.RootRigidbody.velocity = new Vector2(Random.Range(-launchVelocity.x, launchVelocity.x), launchVelocity.y);
ragdoll.RootRigidbody.linearVelocity = new Vector2(Random.Range(-launchVelocity.x, launchVelocity.x), launchVelocity.y);
StartCoroutine(WaitUntilStopped());
}
@ -78,7 +82,11 @@ namespace Spine.Unity.Examples {
if (hit.collider != null)
skeletonPoint = hit.point;
#if USE_COLLIDER_COMPOSITE_OPERATION
ragdoll.RootRigidbody.bodyType = RigidbodyType2D.Kinematic;
#else
ragdoll.RootRigidbody.isKinematic = true;
#endif
ragdoll.SetSkeletonPosition(skeletonPoint);
yield return ragdoll.SmoothMix(0, restoreDuration);
@ -92,7 +100,7 @@ namespace Spine.Unity.Examples {
float t = 0;
while (t < 0.5f) {
t = (ragdoll.RootRigidbody.velocity.magnitude > 0.09f) ? 0 : t + Time.deltaTime;
t = (ragdoll.RootRigidbody.linearVelocity.magnitude > 0.09f) ? 0 : t + Time.deltaTime;
yield return null;
}

View File

@ -33,6 +33,10 @@
#define HINGE_JOINT_2019_BEHAVIOUR
#endif
#if UNITY_2023_1_OR_NEWER
#define USE_COLLIDER_COMPOSITE_OPERATION
#endif
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@ -140,7 +144,11 @@ namespace Spine.Unity.Examples {
RecursivelyCreateBoneProxies(startingBone);
RootRigidbody = boneTable[startingBone].GetComponent<Rigidbody2D>();
#if USE_COLLIDER_COMPOSITE_OPERATION
RootRigidbody.bodyType = pinStartBone ? RigidbodyType2D.Kinematic : RigidbodyType2D.Dynamic;
#else
RootRigidbody.isKinematic = pinStartBone;
#endif
RootRigidbody.mass = rootMass;
List<Collider2D> boneColliders = new List<Collider2D>();
foreach (KeyValuePair<Bone, Transform> pair in boneTable) {

View File

@ -27,6 +27,10 @@
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#if UNITY_2022_2_OR_NEWER
#define USE_FIND_OBJECTS_BY_TYPE
#endif
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Callbacks;
@ -54,7 +58,11 @@ namespace Spine.Unity {
[DidReloadScripts]
private static void OnReloaded () {
// Force start when scripts are reloaded
#if USE_FIND_OBJECTS_BY_TYPE
EditorSkeletonPlayer[] editorSpineAnimations = FindObjectsByType<EditorSkeletonPlayer>(FindObjectsSortMode.None);
#else
EditorSkeletonPlayer[] editorSpineAnimations = FindObjectsOfType<EditorSkeletonPlayer>();
#endif
foreach (EditorSkeletonPlayer editorSpineAnimation in editorSpineAnimations)
editorSpineAnimation.Start();

View File

@ -31,6 +31,10 @@
#define NEW_PREFAB_SYSTEM
#endif
#if UNITY_2023_1_OR_NEWER
#define USE_COLLIDER_COMPOSITE_OPERATION
#endif
using System.Collections.Generic;
using UnityEngine;
@ -165,7 +169,12 @@ namespace Spine.Unity {
SkeletonUtility.SetColliderPointsLocal(bbCollider, slot, boundingBoxAttachment);
bbCollider.isTrigger = isTrigger;
bbCollider.usedByEffector = usedByEffector;
#if USE_COLLIDER_COMPOSITE_OPERATION
bbCollider.compositeOperation = usedByComposite ?
Collider2D.CompositeOperation.Merge : Collider2D.CompositeOperation.None;
#else
bbCollider.usedByComposite = usedByComposite;
#endif
bbCollider.enabled = false;
bbCollider.hideFlags = HideFlags.NotEditable;
colliderTable.Add(boundingBoxAttachment, bbCollider);
@ -205,7 +214,7 @@ namespace Spine.Unity {
DestroyImmediate(collider);
else
#endif
Destroy(collider);
Destroy(collider);
}
}
}

View File

@ -31,6 +31,10 @@
#define NEW_PREFAB_SYSTEM
#endif
#if UNITY_2023_1_OR_NEWER
#define USE_COLLIDER_COMPOSITE_OPERATION
#endif
using System.Collections.Generic;
using UnityEngine;
@ -166,7 +170,12 @@ namespace Spine.Unity {
SkeletonUtility.SetColliderPointsLocal(bbCollider, slot, boundingBoxAttachment, scale);
bbCollider.isTrigger = isTrigger;
bbCollider.usedByEffector = usedByEffector;
#if USE_COLLIDER_COMPOSITE_OPERATION
bbCollider.compositeOperation = usedByComposite ?
Collider2D.CompositeOperation.Merge : Collider2D.CompositeOperation.None;
#else
bbCollider.usedByComposite = usedByComposite;
#endif
bbCollider.enabled = false;
bbCollider.hideFlags = HideFlags.NotEditable;
colliderTable.Add(boundingBoxAttachment, bbCollider);

View File

@ -27,6 +27,10 @@
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#if UNITY_6000_0_OR_NEWER
#define RIGIDBODY2D_USES_LINEAR_VELOCITY
#endif
// In order to respect TransformConstraints modifying the scale of parent bones,
// GetScaleAffectingRootMotion() now uses parentBone.AScaleX and AScaleY instead
// of previously used ScaleX and ScaleY. If you require the previous behaviour,
@ -215,9 +219,15 @@ namespace Spine.Unity {
float deltaTime = Time.fixedDeltaTime;
float deltaTimeSquared = (deltaTime * deltaTime);
#if RIGIDBODY2D_USES_LINEAR_VELOCITY
rigidBody2D.linearVelocity += rigidBody2D.gravityScale * Physics2D.gravity * deltaTime;
gravityAndVelocityMovement = 0.5f * rigidBody2D.gravityScale * Physics2D.gravity * deltaTimeSquared +
rigidBody2D.linearVelocity * deltaTime;
#else
rigidBody2D.velocity += rigidBody2D.gravityScale * Physics2D.gravity * deltaTime;
gravityAndVelocityMovement = 0.5f * rigidBody2D.gravityScale * Physics2D.gravity * deltaTimeSquared +
rigidBody2D.velocity * deltaTime;
#endif
}
Vector2 rigidbodyDisplacement2D = new Vector2(rigidbodyDisplacement.x, rigidbodyDisplacement.y);

View File

@ -31,6 +31,10 @@
#define NEW_PREFAB_SYSTEM
#endif
#if UNITY_6000_0_OR_NEWER
#define USE_RIGIDBODY_BODY_TYPE
#endif
using System.Collections.Generic;
using UnityEngine;
@ -123,7 +127,11 @@ namespace Spine.Unity {
Rigidbody2D rb = gameObject.GetComponent<Rigidbody2D>();
if (rb == null) {
rb = gameObject.AddComponent<Rigidbody2D>();
#if USE_RIGIDBODY_BODY_TYPE
rb.bodyType = isKinematic ? RigidbodyType2D.Kinematic : RigidbodyType2D.Dynamic;
#else
rb.isKinematic = isKinematic;
#endif
rb.gravityScale = gravityScale;
}
return rb;

View File

@ -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.113",
"version": "4.2.114",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",