mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[unity] BoneFollower.followSkeletonFlip
This commit is contained in:
parent
7e5aa7db2b
commit
0e883f3e3c
@ -47,12 +47,16 @@ namespace Spine.Unity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>If a bone isn't set, boneName is used to find the bone.</summary>
|
/// <summary>If a bone isn't set in code, boneName is used to find the bone.</summary>
|
||||||
[SpineBone(dataField: "skeletonRenderer")]
|
[SpineBone(dataField: "skeletonRenderer")]
|
||||||
public String boneName;
|
public String boneName;
|
||||||
|
|
||||||
public bool followZPosition = true;
|
public bool followZPosition = true;
|
||||||
public bool followBoneRotation = true;
|
public bool followBoneRotation = true;
|
||||||
|
|
||||||
|
[Tooltip("Follows the skeleton's flip state by controlling this Transform's local scale.")]
|
||||||
|
public bool followSkeletonFlip = false;
|
||||||
|
|
||||||
[UnityEngine.Serialization.FormerlySerializedAs("resetOnAwake")]
|
[UnityEngine.Serialization.FormerlySerializedAs("resetOnAwake")]
|
||||||
public bool initializeOnAwake = true;
|
public bool initializeOnAwake = true;
|
||||||
#endregion
|
#endregion
|
||||||
@ -122,6 +126,11 @@ namespace Spine.Unity {
|
|||||||
thisTransform.rotation = Quaternion.Euler(worldRotation.x, worldRotation.y, skeletonTransform.rotation.eulerAngles.z + bone.WorldRotationX);
|
thisTransform.rotation = Quaternion.Euler(worldRotation.x, worldRotation.y, skeletonTransform.rotation.eulerAngles.z + bone.WorldRotationX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (followSkeletonFlip) {
|
||||||
|
float flipScaleY = bone.skeleton.flipX ^ bone.skeleton.flipY ? -1f : 1f;
|
||||||
|
thisTransform.localScale = new Vector3(1f, flipScaleY, 1f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,7 @@ using UnityEngine;
|
|||||||
namespace Spine.Unity.Editor {
|
namespace Spine.Unity.Editor {
|
||||||
[CustomEditor(typeof(BoneFollower))]
|
[CustomEditor(typeof(BoneFollower))]
|
||||||
public class BoneFollowerInspector : UnityEditor.Editor {
|
public class BoneFollowerInspector : UnityEditor.Editor {
|
||||||
SerializedProperty boneName, skeletonRenderer, followZPosition, followBoneRotation;
|
SerializedProperty boneName, skeletonRenderer, followZPosition, followBoneRotation, followSkeletonFlip;
|
||||||
BoneFollower targetBoneFollower;
|
BoneFollower targetBoneFollower;
|
||||||
bool needsReset;
|
bool needsReset;
|
||||||
|
|
||||||
@ -44,6 +44,7 @@ namespace Spine.Unity.Editor {
|
|||||||
boneName = serializedObject.FindProperty("boneName");
|
boneName = serializedObject.FindProperty("boneName");
|
||||||
followBoneRotation = serializedObject.FindProperty("followBoneRotation");
|
followBoneRotation = serializedObject.FindProperty("followBoneRotation");
|
||||||
followZPosition = serializedObject.FindProperty("followZPosition");
|
followZPosition = serializedObject.FindProperty("followZPosition");
|
||||||
|
followSkeletonFlip = serializedObject.FindProperty("followSkeletonFlip");
|
||||||
|
|
||||||
targetBoneFollower = (BoneFollower)target;
|
targetBoneFollower = (BoneFollower)target;
|
||||||
if (targetBoneFollower.SkeletonRenderer != null)
|
if (targetBoneFollower.SkeletonRenderer != null)
|
||||||
@ -80,6 +81,7 @@ namespace Spine.Unity.Editor {
|
|||||||
}
|
}
|
||||||
EditorGUILayout.PropertyField(followBoneRotation);
|
EditorGUILayout.PropertyField(followBoneRotation);
|
||||||
EditorGUILayout.PropertyField(followZPosition);
|
EditorGUILayout.PropertyField(followZPosition);
|
||||||
|
EditorGUILayout.PropertyField(followSkeletonFlip);
|
||||||
} else {
|
} else {
|
||||||
var boneFollowerSkeletonRenderer = targetBoneFollower.skeletonRenderer;
|
var boneFollowerSkeletonRenderer = targetBoneFollower.skeletonRenderer;
|
||||||
if (boneFollowerSkeletonRenderer == null) {
|
if (boneFollowerSkeletonRenderer == null) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user