[unity] Fixed deprecation warnings on Unity 6000.3. Closes #3013.

This commit is contained in:
Harald Csaszar 2026-01-23 21:38:05 +01:00
parent 35f0b1c26e
commit 1af080578d
12 changed files with 78 additions and 4 deletions

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
#if !SPINE_AUTO_UPGRADE_COMPONENTS_OFF
#define AUTO_UPGRADE_TO_43_COMPONENTS
#endif
@ -177,7 +181,12 @@ namespace Spine.Unity {
SkeletonUtility.SetColliderPointsLocal(bbCollider, skeleton, 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);
@ -217,7 +226,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;
@ -165,7 +169,12 @@ namespace Spine.Unity {
SkeletonUtility.SetColliderPointsLocal(bbCollider, skeleton, 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,
@ -213,9 +217,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
#if !SPINE_AUTO_UPGRADE_COMPONENTS_OFF
#define AUTO_UPGRADE_TO_43_COMPONENTS
#endif
@ -128,7 +132,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

@ -27,6 +27,10 @@
* 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 !SPINE_DISABLE_THREADING
#define USE_THREADED_SKELETON_UPDATE
#define USE_THREADED_ANIMATION_UPDATE // requires USE_THREADED_SKELETON_UPDATE enabled
@ -101,7 +105,11 @@ namespace Spine.Unity {
public static SkeletonUpdateSystem Instance {
get {
if (singletonInstance == null) {
#if USE_FIND_OBJECTS_BY_TYPE
singletonInstance = FindFirstObjectByType<SkeletonUpdateSystem>();
#else
singletonInstance = FindObjectOfType<SkeletonUpdateSystem>();
#endif
if (singletonInstance == null) {
GameObject singletonGameObject = new GameObject("SkeletonUpdateSystem");
singletonInstance = singletonGameObject.AddComponent<SkeletonUpdateSystem>();

View File

@ -27,7 +27,9 @@
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#if !SPINE_DISABLE_THREADING
#define USE_THREADED_ANIMATION_UPDATE
#endif
using Spine.Unity;
using System.Collections;

View File

@ -27,7 +27,9 @@
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#if !SPINE_DISABLE_THREADING
#define USE_THREADED_ANIMATION_UPDATE
#endif
using System.Collections;
using System.Collections.Generic;

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

@ -27,7 +27,9 @@
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#if !SPINE_DISABLE_THREADING
#define USE_THREADED_SKELETON_UPDATE
#endif
using System;
using System.Collections;

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;
@ -138,7 +142,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

@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.spine-unity",
"displayName": "spine-unity Runtime",
"description": "This plugin provides the spine-unity runtime core and examples. Spine Examples can be installed via the Samples tab.",
"version": "4.3.38",
"version": "4.3.39",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",