Merge branch '3.8' into 3.9-beta

This commit is contained in:
Harald Csaszar 2020-03-17 11:42:56 +01:00
commit 30eae619d2
2 changed files with 7 additions and 3 deletions

View File

@ -319,7 +319,8 @@ namespace Spine.Unity.Editor {
GameObject commonParentObject = new GameObject(skeletonUtility.name + " HingeChain Parent " + utilityBone.name); GameObject commonParentObject = new GameObject(skeletonUtility.name + " HingeChain Parent " + utilityBone.name);
var commonParentActivateOnFlip = commonParentObject.AddComponent<ActivateBasedOnFlipDirection>(); var commonParentActivateOnFlip = commonParentObject.AddComponent<ActivateBasedOnFlipDirection>();
commonParentActivateOnFlip.skeletonRenderer = skeletonUtility.SkeletonComponent; commonParentActivateOnFlip.skeletonRenderer = skeletonUtility.skeletonRenderer;
commonParentActivateOnFlip.skeletonGraphic = skeletonUtility.skeletonGraphic;
// HingeChain Parent // HingeChain Parent
// Needs to be on top hierarchy level (not attached to the moving skeleton at least) for physics to apply proper momentum. // Needs to be on top hierarchy level (not attached to the moving skeleton at least) for physics to apply proper momentum.

View File

@ -39,21 +39,24 @@ namespace Spine.Unity {
/// </summary> /// </summary>
public class ActivateBasedOnFlipDirection : MonoBehaviour { public class ActivateBasedOnFlipDirection : MonoBehaviour {
public ISkeletonComponent skeletonRenderer; public SkeletonRenderer skeletonRenderer;
public SkeletonGraphic skeletonGraphic;
public GameObject activeOnNormalX; public GameObject activeOnNormalX;
public GameObject activeOnFlippedX; public GameObject activeOnFlippedX;
HingeJoint2D[] jointsNormalX; HingeJoint2D[] jointsNormalX;
HingeJoint2D[] jointsFlippedX; HingeJoint2D[] jointsFlippedX;
ISkeletonComponent skeletonComponent;
bool wasFlippedXBefore = false; bool wasFlippedXBefore = false;
private void Start () { private void Start () {
jointsNormalX = activeOnNormalX.GetComponentsInChildren<HingeJoint2D>(); jointsNormalX = activeOnNormalX.GetComponentsInChildren<HingeJoint2D>();
jointsFlippedX = activeOnFlippedX.GetComponentsInChildren<HingeJoint2D>(); jointsFlippedX = activeOnFlippedX.GetComponentsInChildren<HingeJoint2D>();
skeletonComponent = skeletonRenderer != null ? (ISkeletonComponent)skeletonRenderer : (ISkeletonComponent)skeletonGraphic;
} }
private void FixedUpdate () { private void FixedUpdate () {
bool isFlippedX = (skeletonRenderer.Skeleton.ScaleX < 0); bool isFlippedX = (skeletonComponent.Skeleton.ScaleX < 0);
if (isFlippedX != wasFlippedXBefore) { if (isFlippedX != wasFlippedXBefore) {
HandleFlip(isFlippedX); HandleFlip(isFlippedX);
} }