mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[unity] Disabled HingeChain2D code.
This commit is contained in:
parent
b7b839063b
commit
9e89e37c54
@ -28,8 +28,10 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
//#define HINGECHAIN2D
|
||||||
// Contributed by: Mitch Thompson
|
// Contributed by: Mitch Thompson
|
||||||
|
|
||||||
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -277,6 +279,54 @@ namespace Spine.Unity.Editor {
|
|||||||
EditorGUIUtility.PingObject(go);
|
EditorGUIUtility.PingObject(go);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if HINGECHAIN2D
|
||||||
|
bool CanCreateHingeChain () {
|
||||||
|
if (utilityBone == null) return false;
|
||||||
|
if (utilityBone.GetComponent<Rigidbody2D>() != null) return false;
|
||||||
|
if (utilityBone.bone != null && utilityBone.bone.Children.Count == 0) return false;
|
||||||
|
var rigidbodies = utilityBone.GetComponentsInChildren<Rigidbody2D>();
|
||||||
|
return rigidbodies.Length <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateHingeChain () {
|
||||||
|
var utilBoneArr = utilityBone.GetComponentsInChildren<SkeletonUtilityBone>();
|
||||||
|
|
||||||
|
foreach (var utilBone in utilBoneArr) {
|
||||||
|
if (utilBone.GetComponent<Collider2D>() == null) {
|
||||||
|
if (utilBone.bone.Data.Length == 0) {
|
||||||
|
var sphere = utilBone.gameObject.AddComponent<CircleCollider2D>();
|
||||||
|
sphere.radius = 0.1f;
|
||||||
|
} else {
|
||||||
|
float length = utilBone.bone.Data.Length;
|
||||||
|
var box = utilBone.gameObject.AddComponent<BoxCollider2D>();
|
||||||
|
box.size = new Vector3(length, length / 3f, 0.2f);
|
||||||
|
box.offset = new Vector3(length / 2f, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
utilBone.gameObject.AddComponent<Rigidbody2D>();
|
||||||
|
}
|
||||||
|
|
||||||
|
utilityBone.GetComponent<Rigidbody2D>().isKinematic = true;
|
||||||
|
|
||||||
|
foreach (var utilBone in utilBoneArr) {
|
||||||
|
if (utilBone == utilityBone)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
utilBone.mode = SkeletonUtilityBone.Mode.Override;
|
||||||
|
|
||||||
|
var joint = utilBone.gameObject.AddComponent<HingeJoint2D>();
|
||||||
|
joint.connectedBody = utilBone.transform.parent.GetComponent<Rigidbody2D>();
|
||||||
|
joint.useLimits = true;
|
||||||
|
joint.limits = new JointAngleLimits2D {
|
||||||
|
min = -20,
|
||||||
|
max = 20
|
||||||
|
};
|
||||||
|
utilBone.GetComponent<Rigidbody2D>().mass = utilBone.transform.parent.GetComponent<Rigidbody2D>().mass * 0.75f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
bool CanCreateHingeChain () {
|
bool CanCreateHingeChain () {
|
||||||
if (utilityBone == null)
|
if (utilityBone == null)
|
||||||
return false;
|
return false;
|
||||||
@ -285,7 +335,7 @@ namespace Spine.Unity.Editor {
|
|||||||
if (utilityBone.bone != null && utilityBone.bone.Children.Count == 0)
|
if (utilityBone.bone != null && utilityBone.bone.Children.Count == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Rigidbody[] rigidbodies = utilityBone.GetComponentsInChildren<Rigidbody>();
|
var rigidbodies = utilityBone.GetComponentsInChildren<Rigidbody>();
|
||||||
|
|
||||||
return rigidbodies.Length <= 0;
|
return rigidbodies.Length <= 0;
|
||||||
}
|
}
|
||||||
@ -332,6 +382,7 @@ namespace Spine.Unity.Editor {
|
|||||||
|
|
||||||
utilBone.gameObject.AddComponent<Rigidbody>();
|
utilBone.gameObject.AddComponent<Rigidbody>();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user