diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/EditorSkeletonPlayer.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/EditorSkeletonPlayer.cs index 13659b8f9..f041b0f17 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/EditorSkeletonPlayer.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/EditorSkeletonPlayer.cs @@ -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(FindObjectsSortMode.None); +#else EditorSkeletonPlayer[] editorSpineAnimations = FindObjectsOfType(); +#endif foreach (EditorSkeletonPlayer editorSpineAnimation in editorSpineAnimations) editorSpineAnimation.Start(); diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollower.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollower.cs index fb9a4ca8a..9ad78fec5 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollower.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollower.cs @@ -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); } } } diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollowerGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollowerGraphic.cs index e7260282c..6c36476f3 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollowerGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/Following/BoundingBoxFollowerGraphic.cs @@ -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); diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotionBase.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotionBase.cs index edfd47581..0f821840f 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotionBase.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/RootMotion/SkeletonRootMotionBase.cs @@ -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); diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtility.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtility.cs index 2c8fcf621..1960bd3ef 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtility.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonUtility/SkeletonUtility.cs @@ -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(); if (rb == null) { rb = gameObject.AddComponent(); +#if USE_RIGIDBODY_BODY_TYPE + rb.bodyType = isKinematic ? RigidbodyType2D.Kinematic : RigidbodyType2D.Dynamic; +#else rb.isKinematic = isKinematic; +#endif rb.gravityScale = gravityScale; } return rb; diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Threading/SkeletonUpdateSystem.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Threading/SkeletonUpdateSystem.cs index bbca35c90..a4ada229e 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Threading/SkeletonUpdateSystem.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Threading/SkeletonUpdateSystem.cs @@ -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(); +#else singletonInstance = FindObjectOfType(); +#endif if (singletonInstance == null) { GameObject singletonGameObject = new GameObject("SkeletonUpdateSystem"); singletonInstance = singletonGameObject.AddComponent(); diff --git a/spine-unity/Assets/Spine/Samples~/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerView.cs b/spine-unity/Assets/Spine/Samples~/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerView.cs index 92987b66f..714fecc1a 100644 --- a/spine-unity/Assets/Spine/Samples~/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerView.cs +++ b/spine-unity/Assets/Spine/Samples~/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerView.cs @@ -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; diff --git a/spine-unity/Assets/Spine/Samples~/Spine Examples/Scripts/HandleEventWithAudioExample.cs b/spine-unity/Assets/Spine/Samples~/Spine Examples/Scripts/HandleEventWithAudioExample.cs index 883427f02..f1b58c9a5 100644 --- a/spine-unity/Assets/Spine/Samples~/Spine Examples/Scripts/HandleEventWithAudioExample.cs +++ b/spine-unity/Assets/Spine/Samples~/Spine Examples/Scripts/HandleEventWithAudioExample.cs @@ -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; diff --git a/spine-unity/Assets/Spine/Samples~/Spine Examples/Scripts/RaggedySpineboy.cs b/spine-unity/Assets/Spine/Samples~/Spine Examples/Scripts/RaggedySpineboy.cs index 025c4c029..4ae8eb3ec 100644 --- a/spine-unity/Assets/Spine/Samples~/Spine Examples/Scripts/RaggedySpineboy.cs +++ b/spine-unity/Assets/Spine/Samples~/Spine Examples/Scripts/RaggedySpineboy.cs @@ -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; } diff --git a/spine-unity/Assets/Spine/Samples~/Spine Examples/Scripts/Sample Components/Sample VertexEffects/JitterEffectExample.cs b/spine-unity/Assets/Spine/Samples~/Spine Examples/Scripts/Sample Components/Sample VertexEffects/JitterEffectExample.cs index 3474b2866..d23af787d 100644 --- a/spine-unity/Assets/Spine/Samples~/Spine Examples/Scripts/Sample Components/Sample VertexEffects/JitterEffectExample.cs +++ b/spine-unity/Assets/Spine/Samples~/Spine Examples/Scripts/Sample Components/Sample VertexEffects/JitterEffectExample.cs @@ -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; diff --git a/spine-unity/Assets/Spine/Samples~/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll2D.cs b/spine-unity/Assets/Spine/Samples~/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll2D.cs index ebb4f1189..b261548b0 100644 --- a/spine-unity/Assets/Spine/Samples~/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll2D.cs +++ b/spine-unity/Assets/Spine/Samples~/Spine Examples/Scripts/Sample Components/SkeletonUtility Modules/SkeletonRagdoll2D.cs @@ -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(); +#if USE_COLLIDER_COMPOSITE_OPERATION + RootRigidbody.bodyType = pinStartBone ? RigidbodyType2D.Kinematic : RigidbodyType2D.Dynamic; +#else RootRigidbody.isKinematic = pinStartBone; +#endif RootRigidbody.mass = rootMass; List boneColliders = new List(); foreach (KeyValuePair pair in boneTable) { diff --git a/spine-unity/Assets/Spine/package.json b/spine-unity/Assets/Spine/package.json index 233f41559..61402900a 100644 --- a/spine-unity/Assets/Spine/package.json +++ b/spine-unity/Assets/Spine/package.json @@ -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",