|
@@ -47,9 +47,9 @@ namespace Spine.Unity {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /// <summary>If a bone isn't set in code, boneName is used to find the bone.</summary>
|
|
|
|
|
|
+ /// <summary>If a bone isn't set in code, boneName is used to find the bone at the beginning. For runtime switching by name, use SetBoneByName. You can also set the BoneFollower.bone field directly.</summary>
|
|
[SpineBone(dataField: "skeletonRenderer")]
|
|
[SpineBone(dataField: "skeletonRenderer")]
|
|
- public String boneName;
|
|
|
|
|
|
+ [SerializeField] public string boneName;
|
|
|
|
|
|
public bool followZPosition = true;
|
|
public bool followZPosition = true;
|
|
public bool followBoneRotation = true;
|
|
public bool followBoneRotation = true;
|
|
@@ -65,10 +65,25 @@ namespace Spine.Unity {
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
[NonSerialized] public bool valid;
|
|
[NonSerialized] public bool valid;
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// The bone.
|
|
|
|
+ /// </summary>
|
|
[NonSerialized] public Bone bone;
|
|
[NonSerialized] public Bone bone;
|
|
Transform skeletonTransform;
|
|
Transform skeletonTransform;
|
|
bool skeletonTransformIsParent;
|
|
bool skeletonTransformIsParent;
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Sets the target bone by its bone name. Returns false if no bone was found.</summary>
|
|
|
|
+ public bool SetBoneByName (string name) {
|
|
|
|
+ bone = skeletonRenderer.skeleton.FindBone(name);
|
|
|
|
+ if (bone == null) {
|
|
|
|
+ Debug.LogError("Bone not found: " + name, this);
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ boneName = name;
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
public void Awake () {
|
|
public void Awake () {
|
|
if (initializeOnAwake) Initialize();
|
|
if (initializeOnAwake) Initialize();
|
|
}
|
|
}
|
|
@@ -115,10 +130,7 @@ namespace Spine.Unity {
|
|
if (bone == null) {
|
|
if (bone == null) {
|
|
if (string.IsNullOrEmpty(boneName)) return;
|
|
if (string.IsNullOrEmpty(boneName)) return;
|
|
bone = skeletonRenderer.skeleton.FindBone(boneName);
|
|
bone = skeletonRenderer.skeleton.FindBone(boneName);
|
|
- if (bone == null) {
|
|
|
|
- Debug.LogError("Bone not found: " + boneName, this);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+ if (!SetBoneByName(boneName)) return;
|
|
}
|
|
}
|
|
|
|
|
|
Transform thisTransform = this.transform;
|
|
Transform thisTransform = this.transform;
|