public static GameObject AddBoundingBoxFollowerGraphicChild(SkeletonGraphic skeletonGraphic, BoundingBoxFollowerGraphic original = null, string name = "BoundingBoxFollowerGraphic", string slotName = null) { var go = EditorInstantiation.NewGameObject(name, true); go.transform.SetParent(skeletonGraphic.transform, false); go.AddComponent <RectTransform>(); var newFollower = go.AddComponent <BoundingBoxFollowerGraphic>(); if (original != null) { newFollower.slotName = original.slotName; newFollower.isTrigger = original.isTrigger; newFollower.usedByEffector = original.usedByEffector; newFollower.usedByComposite = original.usedByComposite; newFollower.clearStateOnDisable = original.clearStateOnDisable; } if (slotName != null) { newFollower.slotName = slotName; } newFollower.skeletonGraphic = skeletonGraphic; newFollower.Initialize(); Selection.activeGameObject = go; EditorGUIUtility.PingObject(go); return(go); }
public static List <GameObject> AddAllBoundingBoxFollowerGraphicChildren( SkeletonGraphic skeletonGraphic, BoundingBoxFollowerGraphic original = null) { List <GameObject> createdGameObjects = new List <GameObject>(); foreach (var skin in skeletonGraphic.Skeleton.Data.Skins) { var attachments = skin.Attachments; foreach (var entry in attachments) { var boundingBoxAttachment = entry.Attachment as BoundingBoxAttachment; if (boundingBoxAttachment == null) { continue; } int slotIndex = entry.SlotIndex; var slot = skeletonGraphic.Skeleton.Slots.Items[slotIndex]; string slotName = slot.Data.Name; GameObject go = AddBoundingBoxFollowerGraphicChild(skeletonGraphic, original, boundingBoxAttachment.Name, slotName); var boneFollower = go.AddComponent <BoneFollowerGraphic>(); boneFollower.skeletonGraphic = skeletonGraphic; boneFollower.SetBone(slot.Data.BoneData.Name); createdGameObjects.Add(go); } } return(createdGameObjects); }
void InitializeEditor() { skeletonGraphic = serializedObject.FindProperty("skeletonGraphic"); slotName = serializedObject.FindProperty("slotName"); isTrigger = serializedObject.FindProperty("isTrigger"); clearStateOnDisable = serializedObject.FindProperty("clearStateOnDisable"); follower = (BoundingBoxFollowerGraphic)target; }