mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-11 17:48:45 +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")]
|
||||
public String boneName;
|
||||
|
||||
public bool followZPosition = 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")]
|
||||
public bool initializeOnAwake = true;
|
||||
#endregion
|
||||
@ -122,6 +126,11 @@ namespace Spine.Unity {
|
||||
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 {
|
||||
[CustomEditor(typeof(BoneFollower))]
|
||||
public class BoneFollowerInspector : UnityEditor.Editor {
|
||||
SerializedProperty boneName, skeletonRenderer, followZPosition, followBoneRotation;
|
||||
SerializedProperty boneName, skeletonRenderer, followZPosition, followBoneRotation, followSkeletonFlip;
|
||||
BoneFollower targetBoneFollower;
|
||||
bool needsReset;
|
||||
|
||||
@ -44,6 +44,7 @@ namespace Spine.Unity.Editor {
|
||||
boneName = serializedObject.FindProperty("boneName");
|
||||
followBoneRotation = serializedObject.FindProperty("followBoneRotation");
|
||||
followZPosition = serializedObject.FindProperty("followZPosition");
|
||||
followSkeletonFlip = serializedObject.FindProperty("followSkeletonFlip");
|
||||
|
||||
targetBoneFollower = (BoneFollower)target;
|
||||
if (targetBoneFollower.SkeletonRenderer != null)
|
||||
@ -80,6 +81,7 @@ namespace Spine.Unity.Editor {
|
||||
}
|
||||
EditorGUILayout.PropertyField(followBoneRotation);
|
||||
EditorGUILayout.PropertyField(followZPosition);
|
||||
EditorGUILayout.PropertyField(followSkeletonFlip);
|
||||
} else {
|
||||
var boneFollowerSkeletonRenderer = targetBoneFollower.skeletonRenderer;
|
||||
if (boneFollowerSkeletonRenderer == null) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user