mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
[unity] Fixed deprecation warnings on Unity 6000.3. Closes #3013.
This commit is contained in:
parent
35f0b1c26e
commit
1af080578d
@ -27,6 +27,10 @@
|
|||||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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
|
#if UNITY_EDITOR
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEditor.Callbacks;
|
using UnityEditor.Callbacks;
|
||||||
@ -54,7 +58,11 @@ namespace Spine.Unity {
|
|||||||
[DidReloadScripts]
|
[DidReloadScripts]
|
||||||
private static void OnReloaded () {
|
private static void OnReloaded () {
|
||||||
// Force start when scripts are reloaded
|
// Force start when scripts are reloaded
|
||||||
|
#if USE_FIND_OBJECTS_BY_TYPE
|
||||||
|
EditorSkeletonPlayer[] editorSpineAnimations = FindObjectsByType<EditorSkeletonPlayer>(FindObjectsSortMode.None);
|
||||||
|
#else
|
||||||
EditorSkeletonPlayer[] editorSpineAnimations = FindObjectsOfType<EditorSkeletonPlayer>();
|
EditorSkeletonPlayer[] editorSpineAnimations = FindObjectsOfType<EditorSkeletonPlayer>();
|
||||||
|
#endif
|
||||||
|
|
||||||
foreach (EditorSkeletonPlayer editorSpineAnimation in editorSpineAnimations)
|
foreach (EditorSkeletonPlayer editorSpineAnimation in editorSpineAnimations)
|
||||||
editorSpineAnimation.Start();
|
editorSpineAnimation.Start();
|
||||||
|
|||||||
@ -31,6 +31,10 @@
|
|||||||
#define NEW_PREFAB_SYSTEM
|
#define NEW_PREFAB_SYSTEM
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if UNITY_2023_1_OR_NEWER
|
||||||
|
#define USE_COLLIDER_COMPOSITE_OPERATION
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !SPINE_AUTO_UPGRADE_COMPONENTS_OFF
|
#if !SPINE_AUTO_UPGRADE_COMPONENTS_OFF
|
||||||
#define AUTO_UPGRADE_TO_43_COMPONENTS
|
#define AUTO_UPGRADE_TO_43_COMPONENTS
|
||||||
#endif
|
#endif
|
||||||
@ -177,7 +181,12 @@ namespace Spine.Unity {
|
|||||||
SkeletonUtility.SetColliderPointsLocal(bbCollider, skeleton, slot, boundingBoxAttachment);
|
SkeletonUtility.SetColliderPointsLocal(bbCollider, skeleton, slot, boundingBoxAttachment);
|
||||||
bbCollider.isTrigger = isTrigger;
|
bbCollider.isTrigger = isTrigger;
|
||||||
bbCollider.usedByEffector = usedByEffector;
|
bbCollider.usedByEffector = usedByEffector;
|
||||||
|
#if USE_COLLIDER_COMPOSITE_OPERATION
|
||||||
|
bbCollider.compositeOperation = usedByComposite ?
|
||||||
|
Collider2D.CompositeOperation.Merge : Collider2D.CompositeOperation.None;
|
||||||
|
#else
|
||||||
bbCollider.usedByComposite = usedByComposite;
|
bbCollider.usedByComposite = usedByComposite;
|
||||||
|
#endif
|
||||||
bbCollider.enabled = false;
|
bbCollider.enabled = false;
|
||||||
bbCollider.hideFlags = HideFlags.NotEditable;
|
bbCollider.hideFlags = HideFlags.NotEditable;
|
||||||
colliderTable.Add(boundingBoxAttachment, bbCollider);
|
colliderTable.Add(boundingBoxAttachment, bbCollider);
|
||||||
@ -217,7 +226,7 @@ namespace Spine.Unity {
|
|||||||
DestroyImmediate(collider);
|
DestroyImmediate(collider);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
Destroy(collider);
|
Destroy(collider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,6 +31,10 @@
|
|||||||
#define NEW_PREFAB_SYSTEM
|
#define NEW_PREFAB_SYSTEM
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if UNITY_2023_1_OR_NEWER
|
||||||
|
#define USE_COLLIDER_COMPOSITE_OPERATION
|
||||||
|
#endif
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@ -165,7 +169,12 @@ namespace Spine.Unity {
|
|||||||
SkeletonUtility.SetColliderPointsLocal(bbCollider, skeleton, slot, boundingBoxAttachment, scale);
|
SkeletonUtility.SetColliderPointsLocal(bbCollider, skeleton, slot, boundingBoxAttachment, scale);
|
||||||
bbCollider.isTrigger = isTrigger;
|
bbCollider.isTrigger = isTrigger;
|
||||||
bbCollider.usedByEffector = usedByEffector;
|
bbCollider.usedByEffector = usedByEffector;
|
||||||
|
#if USE_COLLIDER_COMPOSITE_OPERATION
|
||||||
|
bbCollider.compositeOperation = usedByComposite ?
|
||||||
|
Collider2D.CompositeOperation.Merge : Collider2D.CompositeOperation.None;
|
||||||
|
#else
|
||||||
bbCollider.usedByComposite = usedByComposite;
|
bbCollider.usedByComposite = usedByComposite;
|
||||||
|
#endif
|
||||||
bbCollider.enabled = false;
|
bbCollider.enabled = false;
|
||||||
bbCollider.hideFlags = HideFlags.NotEditable;
|
bbCollider.hideFlags = HideFlags.NotEditable;
|
||||||
colliderTable.Add(boundingBoxAttachment, bbCollider);
|
colliderTable.Add(boundingBoxAttachment, bbCollider);
|
||||||
|
|||||||
@ -27,6 +27,10 @@
|
|||||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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,
|
// In order to respect TransformConstraints modifying the scale of parent bones,
|
||||||
// GetScaleAffectingRootMotion() now uses parentBone.AScaleX and AScaleY instead
|
// GetScaleAffectingRootMotion() now uses parentBone.AScaleX and AScaleY instead
|
||||||
// of previously used ScaleX and ScaleY. If you require the previous behaviour,
|
// of previously used ScaleX and ScaleY. If you require the previous behaviour,
|
||||||
@ -213,9 +217,15 @@ namespace Spine.Unity {
|
|||||||
float deltaTime = Time.fixedDeltaTime;
|
float deltaTime = Time.fixedDeltaTime;
|
||||||
float deltaTimeSquared = (deltaTime * deltaTime);
|
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;
|
rigidBody2D.velocity += rigidBody2D.gravityScale * Physics2D.gravity * deltaTime;
|
||||||
gravityAndVelocityMovement = 0.5f * rigidBody2D.gravityScale * Physics2D.gravity * deltaTimeSquared +
|
gravityAndVelocityMovement = 0.5f * rigidBody2D.gravityScale * Physics2D.gravity * deltaTimeSquared +
|
||||||
rigidBody2D.velocity * deltaTime;
|
rigidBody2D.velocity * deltaTime;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 rigidbodyDisplacement2D = new Vector2(rigidbodyDisplacement.x, rigidbodyDisplacement.y);
|
Vector2 rigidbodyDisplacement2D = new Vector2(rigidbodyDisplacement.x, rigidbodyDisplacement.y);
|
||||||
|
|||||||
@ -31,6 +31,10 @@
|
|||||||
#define NEW_PREFAB_SYSTEM
|
#define NEW_PREFAB_SYSTEM
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if UNITY_6000_0_OR_NEWER
|
||||||
|
#define USE_RIGIDBODY_BODY_TYPE
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !SPINE_AUTO_UPGRADE_COMPONENTS_OFF
|
#if !SPINE_AUTO_UPGRADE_COMPONENTS_OFF
|
||||||
#define AUTO_UPGRADE_TO_43_COMPONENTS
|
#define AUTO_UPGRADE_TO_43_COMPONENTS
|
||||||
#endif
|
#endif
|
||||||
@ -128,7 +132,11 @@ namespace Spine.Unity {
|
|||||||
Rigidbody2D rb = gameObject.GetComponent<Rigidbody2D>();
|
Rigidbody2D rb = gameObject.GetComponent<Rigidbody2D>();
|
||||||
if (rb == null) {
|
if (rb == null) {
|
||||||
rb = gameObject.AddComponent<Rigidbody2D>();
|
rb = gameObject.AddComponent<Rigidbody2D>();
|
||||||
|
#if USE_RIGIDBODY_BODY_TYPE
|
||||||
|
rb.bodyType = isKinematic ? RigidbodyType2D.Kinematic : RigidbodyType2D.Dynamic;
|
||||||
|
#else
|
||||||
rb.isKinematic = isKinematic;
|
rb.isKinematic = isKinematic;
|
||||||
|
#endif
|
||||||
rb.gravityScale = gravityScale;
|
rb.gravityScale = gravityScale;
|
||||||
}
|
}
|
||||||
return rb;
|
return rb;
|
||||||
|
|||||||
@ -27,6 +27,10 @@
|
|||||||
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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
|
#if !SPINE_DISABLE_THREADING
|
||||||
#define USE_THREADED_SKELETON_UPDATE
|
#define USE_THREADED_SKELETON_UPDATE
|
||||||
#define USE_THREADED_ANIMATION_UPDATE // requires USE_THREADED_SKELETON_UPDATE enabled
|
#define USE_THREADED_ANIMATION_UPDATE // requires USE_THREADED_SKELETON_UPDATE enabled
|
||||||
@ -101,7 +105,11 @@ namespace Spine.Unity {
|
|||||||
public static SkeletonUpdateSystem Instance {
|
public static SkeletonUpdateSystem Instance {
|
||||||
get {
|
get {
|
||||||
if (singletonInstance == null) {
|
if (singletonInstance == null) {
|
||||||
|
#if USE_FIND_OBJECTS_BY_TYPE
|
||||||
|
singletonInstance = FindFirstObjectByType<SkeletonUpdateSystem>();
|
||||||
|
#else
|
||||||
singletonInstance = FindObjectOfType<SkeletonUpdateSystem>();
|
singletonInstance = FindObjectOfType<SkeletonUpdateSystem>();
|
||||||
|
#endif
|
||||||
if (singletonInstance == null) {
|
if (singletonInstance == null) {
|
||||||
GameObject singletonGameObject = new GameObject("SkeletonUpdateSystem");
|
GameObject singletonGameObject = new GameObject("SkeletonUpdateSystem");
|
||||||
singletonInstance = singletonGameObject.AddComponent<SkeletonUpdateSystem>();
|
singletonInstance = singletonGameObject.AddComponent<SkeletonUpdateSystem>();
|
||||||
|
|||||||
@ -27,7 +27,9 @@
|
|||||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#if !SPINE_DISABLE_THREADING
|
||||||
#define USE_THREADED_ANIMATION_UPDATE
|
#define USE_THREADED_ANIMATION_UPDATE
|
||||||
|
#endif
|
||||||
|
|
||||||
using Spine.Unity;
|
using Spine.Unity;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|||||||
@ -27,7 +27,9 @@
|
|||||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#if !SPINE_DISABLE_THREADING
|
||||||
#define USE_THREADED_ANIMATION_UPDATE
|
#define USE_THREADED_ANIMATION_UPDATE
|
||||||
|
#endif
|
||||||
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
@ -27,6 +27,10 @@
|
|||||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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 Spine.Unity;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -65,7 +69,7 @@ namespace Spine.Unity.Examples {
|
|||||||
void Launch () {
|
void Launch () {
|
||||||
RemoveRigidbody();
|
RemoveRigidbody();
|
||||||
ragdoll.Apply();
|
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());
|
StartCoroutine(WaitUntilStopped());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +82,11 @@ namespace Spine.Unity.Examples {
|
|||||||
if (hit.collider != null)
|
if (hit.collider != null)
|
||||||
skeletonPoint = hit.point;
|
skeletonPoint = hit.point;
|
||||||
|
|
||||||
|
#if USE_COLLIDER_COMPOSITE_OPERATION
|
||||||
|
ragdoll.RootRigidbody.bodyType = RigidbodyType2D.Kinematic;
|
||||||
|
#else
|
||||||
ragdoll.RootRigidbody.isKinematic = true;
|
ragdoll.RootRigidbody.isKinematic = true;
|
||||||
|
#endif
|
||||||
ragdoll.SetSkeletonPosition(skeletonPoint);
|
ragdoll.SetSkeletonPosition(skeletonPoint);
|
||||||
|
|
||||||
yield return ragdoll.SmoothMix(0, restoreDuration);
|
yield return ragdoll.SmoothMix(0, restoreDuration);
|
||||||
@ -92,7 +100,7 @@ namespace Spine.Unity.Examples {
|
|||||||
|
|
||||||
float t = 0;
|
float t = 0;
|
||||||
while (t < 0.5f) {
|
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;
|
yield return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,9 @@
|
|||||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#if !SPINE_DISABLE_THREADING
|
||||||
#define USE_THREADED_SKELETON_UPDATE
|
#define USE_THREADED_SKELETON_UPDATE
|
||||||
|
#endif
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|||||||
@ -33,6 +33,10 @@
|
|||||||
#define HINGE_JOINT_2019_BEHAVIOUR
|
#define HINGE_JOINT_2019_BEHAVIOUR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if UNITY_2023_1_OR_NEWER
|
||||||
|
#define USE_COLLIDER_COMPOSITE_OPERATION
|
||||||
|
#endif
|
||||||
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -138,7 +142,11 @@ namespace Spine.Unity.Examples {
|
|||||||
RecursivelyCreateBoneProxies(startingBone);
|
RecursivelyCreateBoneProxies(startingBone);
|
||||||
|
|
||||||
RootRigidbody = boneTable[startingBone].GetComponent<Rigidbody2D>();
|
RootRigidbody = boneTable[startingBone].GetComponent<Rigidbody2D>();
|
||||||
|
#if USE_COLLIDER_COMPOSITE_OPERATION
|
||||||
|
RootRigidbody.bodyType = pinStartBone ? RigidbodyType2D.Kinematic : RigidbodyType2D.Dynamic;
|
||||||
|
#else
|
||||||
RootRigidbody.isKinematic = pinStartBone;
|
RootRigidbody.isKinematic = pinStartBone;
|
||||||
|
#endif
|
||||||
RootRigidbody.mass = rootMass;
|
RootRigidbody.mass = rootMass;
|
||||||
List<Collider2D> boneColliders = new List<Collider2D>();
|
List<Collider2D> boneColliders = new List<Collider2D>();
|
||||||
foreach (KeyValuePair<Bone, Transform> pair in boneTable) {
|
foreach (KeyValuePair<Bone, Transform> pair in boneTable) {
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"name": "com.esotericsoftware.spine.spine-unity",
|
"name": "com.esotericsoftware.spine.spine-unity",
|
||||||
"displayName": "spine-unity Runtime",
|
"displayName": "spine-unity Runtime",
|
||||||
"description": "This plugin provides the spine-unity runtime core and examples. Spine Examples can be installed via the Samples tab.",
|
"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",
|
"unity": "2018.3",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Esoteric Software",
|
"name": "Esoteric Software",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user