mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[unity] SkeletonUtility spawn methods were not saved in Prefab mode. Closes #1481.
This commit is contained in:
parent
4c1e01474e
commit
9483df76b5
@ -143,21 +143,25 @@ namespace Spine.Unity.Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpawnFollowHierarchy () {
|
void SpawnFollowHierarchy () {
|
||||||
|
Undo.RegisterCompleteObjectUndo(skeletonUtility, "Spawn Hierarchy");
|
||||||
Selection.activeGameObject = skeletonUtility.SpawnHierarchy(SkeletonUtilityBone.Mode.Follow, true, true, true);
|
Selection.activeGameObject = skeletonUtility.SpawnHierarchy(SkeletonUtilityBone.Mode.Follow, true, true, true);
|
||||||
AttachIconsToChildren(skeletonUtility.boneRoot);
|
AttachIconsToChildren(skeletonUtility.boneRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpawnFollowHierarchyRootOnly () {
|
void SpawnFollowHierarchyRootOnly () {
|
||||||
|
Undo.RegisterCompleteObjectUndo(skeletonUtility, "Spawn Root");
|
||||||
Selection.activeGameObject = skeletonUtility.SpawnRoot(SkeletonUtilityBone.Mode.Follow, true, true, true);
|
Selection.activeGameObject = skeletonUtility.SpawnRoot(SkeletonUtilityBone.Mode.Follow, true, true, true);
|
||||||
AttachIconsToChildren(skeletonUtility.boneRoot);
|
AttachIconsToChildren(skeletonUtility.boneRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpawnOverrideHierarchy () {
|
void SpawnOverrideHierarchy () {
|
||||||
|
Undo.RegisterCompleteObjectUndo(skeletonUtility, "Spawn Hierarchy");
|
||||||
Selection.activeGameObject = skeletonUtility.SpawnHierarchy(SkeletonUtilityBone.Mode.Override, true, true, true);
|
Selection.activeGameObject = skeletonUtility.SpawnHierarchy(SkeletonUtilityBone.Mode.Override, true, true, true);
|
||||||
AttachIconsToChildren(skeletonUtility.boneRoot);
|
AttachIconsToChildren(skeletonUtility.boneRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpawnOverrideHierarchyRootOnly () {
|
void SpawnOverrideHierarchyRootOnly () {
|
||||||
|
Undo.RegisterCompleteObjectUndo(skeletonUtility, "Spawn Root");
|
||||||
Selection.activeGameObject = skeletonUtility.SpawnRoot(SkeletonUtilityBone.Mode.Override, true, true, true);
|
Selection.activeGameObject = skeletonUtility.SpawnRoot(SkeletonUtilityBone.Mode.Override, true, true, true);
|
||||||
AttachIconsToChildren(skeletonUtility.boneRoot);
|
AttachIconsToChildren(skeletonUtility.boneRoot);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,6 +70,10 @@ namespace Spine.Unity {
|
|||||||
|
|
||||||
public static PolygonCollider2D AddBoundingBoxGameObject (string name, BoundingBoxAttachment box, Slot slot, Transform parent, bool isTrigger = true) {
|
public static PolygonCollider2D AddBoundingBoxGameObject (string name, BoundingBoxAttachment box, Slot slot, Transform parent, bool isTrigger = true) {
|
||||||
var go = new GameObject("[BoundingBox]" + (string.IsNullOrEmpty(name) ? box.Name : name));
|
var go = new GameObject("[BoundingBox]" + (string.IsNullOrEmpty(name) ? box.Name : name));
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
if (!Application.isPlaying)
|
||||||
|
UnityEditor.Undo.RegisterCreatedObjectUndo(go, "Spawn BoundingBox");
|
||||||
|
# endif
|
||||||
var got = go.transform;
|
var got = go.transform;
|
||||||
got.parent = parent;
|
got.parent = parent;
|
||||||
got.localPosition = Vector3.zero;
|
got.localPosition = Vector3.zero;
|
||||||
@ -145,7 +149,7 @@ namespace Spine.Unity {
|
|||||||
OnDisable();
|
OnDisable();
|
||||||
OnEnable();
|
OnEnable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnEnable () {
|
void OnEnable () {
|
||||||
if (skeletonRenderer == null) {
|
if (skeletonRenderer == null) {
|
||||||
skeletonRenderer = GetComponent<SkeletonRenderer>();
|
skeletonRenderer = GetComponent<SkeletonRenderer>();
|
||||||
@ -291,6 +295,10 @@ namespace Spine.Unity {
|
|||||||
return boneRoot;
|
return boneRoot;
|
||||||
|
|
||||||
boneRoot = new GameObject("SkeletonUtility-SkeletonRoot").transform;
|
boneRoot = new GameObject("SkeletonUtility-SkeletonRoot").transform;
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
if (!Application.isPlaying)
|
||||||
|
UnityEditor.Undo.RegisterCreatedObjectUndo(boneRoot.gameObject, "Spawn Bone");
|
||||||
|
#endif
|
||||||
boneRoot.parent = transform;
|
boneRoot.parent = transform;
|
||||||
boneRoot.localPosition = Vector3.zero;
|
boneRoot.localPosition = Vector3.zero;
|
||||||
boneRoot.localRotation = Quaternion.identity;
|
boneRoot.localRotation = Quaternion.identity;
|
||||||
@ -330,6 +338,10 @@ namespace Spine.Unity {
|
|||||||
|
|
||||||
public GameObject SpawnBone (Bone bone, Transform parent, SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca) {
|
public GameObject SpawnBone (Bone bone, Transform parent, SkeletonUtilityBone.Mode mode, bool pos, bool rot, bool sca) {
|
||||||
GameObject go = new GameObject(bone.Data.Name);
|
GameObject go = new GameObject(bone.Data.Name);
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
if (!Application.isPlaying)
|
||||||
|
UnityEditor.Undo.RegisterCreatedObjectUndo(go, "Spawn Bone");
|
||||||
|
#endif
|
||||||
var goTransform = go.transform;
|
var goTransform = go.transform;
|
||||||
goTransform.parent = parent;
|
goTransform.parent = parent;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user