private List <Collider> AttachBoundingBoxRagdollColliders(Bone b) { List <Collider> list = new List <Collider>(); Transform transform = this.boneTable[b]; GameObject gameObject = transform.gameObject; Skin skin = this.skeleton.Skin ?? this.skeleton.Data.DefaultSkin; List <Attachment> list2 = new List <Attachment>(); foreach (Slot slot in this.skeleton.Slots) { if (slot.Bone == b) { skin.FindAttachmentsForSlot(this.skeleton.Slots.IndexOf(slot), list2); foreach (Attachment attachment in list2) { BoundingBoxAttachment boundingBoxAttachment = attachment as BoundingBoxAttachment; if (boundingBoxAttachment != null) { if (attachment.Name.ToLower().Contains("ragdoll")) { BoxCollider boxCollider = gameObject.AddComponent <BoxCollider>(); Bounds boundingBoxBounds = SkeletonUtility.GetBoundingBoxBounds(boundingBoxAttachment, this.thickness); boxCollider.center = boundingBoxBounds.center; boxCollider.size = boundingBoxBounds.size; list.Add(boxCollider); } } } } } return(list); }
private static List <Collider2D> AttachBoundingBoxRagdollColliders(Bone b, GameObject go, Skeleton skeleton) { List <Collider2D> list = new List <Collider2D>(); Skin skin = skeleton.Skin ?? skeleton.Data.DefaultSkin; List <Attachment> list2 = new List <Attachment>(); foreach (Slot slot in skeleton.Slots) { if (slot.bone == b) { skin.FindAttachmentsForSlot(skeleton.Slots.IndexOf(slot), list2); foreach (Attachment attachment in list2) { BoundingBoxAttachment boundingBoxAttachment = attachment as BoundingBoxAttachment; if (boundingBoxAttachment != null) { if (attachment.Name.ToLower().Contains("ragdoll")) { PolygonCollider2D item = SkeletonUtility.AddBoundingBoxAsComponent(boundingBoxAttachment, go, false); list.Add(item); } } } } } return(list); }
void EvaluateFlags () { utilityBone = (SkeletonUtilityBone)target; skeletonUtility = utilityBone.skeletonUtility; if (Selection.objects.Length == 1) { containsFollows = utilityBone.mode == SkeletonUtilityBone.Mode.Follow; containsOverrides = utilityBone.mode == SkeletonUtilityBone.Mode.Override; } else { int boneCount = 0; foreach (Object o in Selection.objects) { if (o is GameObject) { GameObject go = (GameObject)o; SkeletonUtilityBone sub = go.GetComponent<SkeletonUtilityBone>(); if (sub != null) { boneCount++; if (sub.mode == SkeletonUtilityBone.Mode.Follow) containsFollows = true; if (sub.mode == SkeletonUtilityBone.Mode.Override) containsOverrides = true; } } } if (boneCount > 1) multiObject = true; } }
void EvaluateFlags() { utilityBone = (SkeletonUtilityBone)target; skeletonUtility = utilityBone.hierarchy; if (Selection.objects.Length == 1) { containsFollows = utilityBone.mode == SkeletonUtilityBone.Mode.Follow; containsOverrides = utilityBone.mode == SkeletonUtilityBone.Mode.Override; } else { int boneCount = 0; foreach (Object o in Selection.objects) { var go = o as GameObject; if (go != null) { SkeletonUtilityBone sub = go.GetComponent <SkeletonUtilityBone>(); if (sub != null) { boneCount++; containsFollows |= (sub.mode == SkeletonUtilityBone.Mode.Follow); containsOverrides |= (sub.mode == SkeletonUtilityBone.Mode.Override); } } } multiObject |= (boneCount > 1); } }
private static List <Collider2D> AttachBoundingBoxRagdollColliders(Bone b, GameObject go, Skeleton skeleton, float gravityScale) { Skin defaultSkin; List <Collider2D> list = new List <Collider2D>(); Skin skin1 = skeleton.Skin; if (skin1 != null) { defaultSkin = skin1; } else { defaultSkin = skeleton.Data.DefaultSkin; } List <Attachment> attachments = new List <Attachment>(); foreach (Slot slot in skeleton.Slots) { if (slot.bone == b) { defaultSkin.FindAttachmentsForSlot(skeleton.Slots.IndexOf(slot), attachments); foreach (Attachment attachment in attachments) { BoundingBoxAttachment box = attachment as BoundingBoxAttachment; if ((box != null) && attachment.Name.ToLower().Contains("ragdoll")) { PolygonCollider2D item = SkeletonUtility.AddBoundingBoxAsComponent(box, slot, go, false, false, gravityScale); list.Add(item); } } } } return(list); }
static List <Collider2D> AttachBoundingBoxRagdollColliders(Bone b, GameObject go, Skeleton skeleton, float gravityScale) { const string AttachmentNameMarker = "ragdoll"; var colliders = new List <Collider2D>(); var skin = skeleton.Skin ?? skeleton.Data.DefaultSkin; var attachments = new List <Attachment>(); foreach (Slot s in skeleton.Slots) { if (s.bone == b) { skin.FindAttachmentsForSlot(skeleton.Slots.IndexOf(s), attachments); foreach (var a in attachments) { var bbAttachment = a as BoundingBoxAttachment; if (bbAttachment != null) { if (!a.Name.ToLower().Contains(AttachmentNameMarker)) { continue; } var bbCollider = SkeletonUtility.AddBoundingBoxAsComponent(bbAttachment, s, go, isTrigger: false, isKinematic: false, gravityScale: gravityScale); colliders.Add(bbCollider); } } } } return(colliders); }
void OnEnable() { skeletonUtility = (SkeletonUtility)target; skeletonRenderer = skeletonUtility.skeletonRenderer; skeletonGraphic = skeletonUtility.skeletonGraphic; skeleton = skeletonUtility.Skeleton; if (skeleton == null) { if (skeletonRenderer != null) { skeletonRenderer.Initialize(false); skeletonRenderer.LateUpdate(); } else if (skeletonGraphic != null) { skeletonGraphic.Initialize(false); skeletonGraphic.LateUpdate(); } skeleton = skeletonUtility.Skeleton; } if ((skeletonRenderer != null && !skeletonRenderer.valid) || (skeletonGraphic != null && !skeletonGraphic.IsValid)) { return; } #if !NEW_PREFAB_SYSTEM isPrefab |= PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab; #endif }
public void HandleReset(SkeletonRenderer renderer) { if (slotName == null || slotName == "") { return; } hasReset = true; ClearColliders(); colliderTable.Clear(); if (skeletonRenderer.skeleton == null) { skeletonRenderer.OnReset -= HandleReset; skeletonRenderer.Reset(); skeletonRenderer.OnReset += HandleReset; } var skeleton = skeletonRenderer.skeleton; slot = skeleton.FindSlot(slotName); int slotIndex = skeleton.FindSlotIndex(slotName); foreach (var skin in skeleton.Data.Skins) { List <string> attachmentNames = new List <string>(); skin.FindNamesForSlot(slotIndex, attachmentNames); foreach (var name in attachmentNames) { var attachment = skin.GetAttachment(slotIndex, name); if (attachment is BoundingBoxAttachment) { var collider = SkeletonUtility.AddBoundingBoxAsComponent((BoundingBoxAttachment)attachment, gameObject, true); collider.enabled = false; collider.hideFlags = HideFlags.HideInInspector; colliderTable.Add((BoundingBoxAttachment)attachment, collider); attachmentNameTable.Add((BoundingBoxAttachment)attachment, name); } } } if (colliderTable.Count == 0) { valid = false; } else { valid = true; } if (!valid) { Debug.LogWarning("Bounding Box Follower not valid! Slot [" + slotName + "] does not contain any Bounding Box Attachments!"); } }
public void HandleReset(SkeletonRenderer renderer) { if (this.slotName == null || this.slotName == string.Empty) { return; } this.hasReset = true; this.ClearColliders(); this.colliderTable.Clear(); if (this.skeletonRenderer.skeleton == null) { SkeletonRenderer expr_4F = this.skeletonRenderer; expr_4F.OnReset = (SkeletonRenderer.SkeletonRendererDelegate)Delegate.Remove(expr_4F.OnReset, new SkeletonRenderer.SkeletonRendererDelegate(this.HandleReset)); this.skeletonRenderer.Reset(); SkeletonRenderer expr_81 = this.skeletonRenderer; expr_81.OnReset = (SkeletonRenderer.SkeletonRendererDelegate)Delegate.Combine(expr_81.OnReset, new SkeletonRenderer.SkeletonRendererDelegate(this.HandleReset)); } Skeleton skeleton = this.skeletonRenderer.skeleton; this.slot = skeleton.FindSlot(this.slotName); int slotIndex = skeleton.FindSlotIndex(this.slotName); foreach (Skin current in skeleton.Data.Skins) { List <string> list = new List <string>(); current.FindNamesForSlot(slotIndex, list); using (List <string> .Enumerator enumerator2 = list.GetEnumerator()) { while (enumerator2.MoveNext()) { string current2 = enumerator2.get_Current(); Attachment attachment = current.GetAttachment(slotIndex, current2); if (attachment is BoundingBoxAttachment) { PolygonCollider2D polygonCollider2D = SkeletonUtility.AddBoundingBoxAsComponent((BoundingBoxAttachment)attachment, base.get_gameObject(), true); polygonCollider2D.set_enabled(false); polygonCollider2D.set_hideFlags(2); this.colliderTable.Add((BoundingBoxAttachment)attachment, polygonCollider2D); this.attachmentNameTable.Add((BoundingBoxAttachment)attachment, current2); } } } } if (this.colliderTable.get_Count() == 0) { this.valid = false; } else { this.valid = true; } if (!this.valid) { Debug.LogWarning("Bounding Box Follower not valid! Slot [" + this.slotName + "] does not contain any Bounding Box Attachments!"); } }
private void OnEnable() { this.skeletonUtility = SkeletonUtility.GetInParent <SkeletonUtility>(base.get_transform()); if (this.skeletonUtility == null) { return; } this.skeletonUtility.RegisterBone(this); this.skeletonUtility.OnReset += new SkeletonUtility.SkeletonUtilityDelegate(this.HandleOnReset); }
void OnEnable () { skeletonUtility = SkeletonUtility.GetInParent<SkeletonUtility>(transform); if (skeletonUtility == null) return; skeletonUtility.RegisterBone(this); skeletonUtility.OnReset += HandleOnReset; }
void Awake() { if (AnimationObj != null) { skeletonAnimation = AnimationObj.GetComponent <SkeletonAnimation>(); render = AnimationObj.GetComponent <Renderer>(); skeletonUtility = AnimationObj.GetComponent <SkeletonUtility>(); } cardInfo = GetComponent <CardInfo>(); }
// Use this for initialization void Start() { sktAnimator = GetComponent<SkeletonAnimator>(); if (sktAnimator == null) { Debug.LogError("sktAnimator == null"); } else { sktAnimator.GetSkeleton().flipX = true; sktAnimator.GetSkeleton().SetColor(new Color(1.0f, 0.0f, 0.0f)); } sktAnimation = GetComponent<SkeletonAnimation>(); if (sktAnimation == null) { Debug.LogError("sktAnimation == null"); } else { Debug.Log("animation : " + sktAnimation.state.GetCurrent(0)); } animator = GetComponent<Animator>(); if (animator == null) { Debug.LogError("animator == null"); } else { AnimatorClipInfo[] items = animator.GetCurrentAnimatorClipInfo(0); Debug.Log("items length : " + items.Length); foreach (AnimatorClipInfo item in items) { Debug.Log("" + item.clip.name); } Debug.Log("ok"); // Debug.Log ("animator : " + animator.GetComponent<UnityEngine.Animation>().name); } sktUtility = GetComponent<SkeletonUtility>(); if (sktUtility == null) { Debug.LogError ("sktUtility == null"); } else { Debug.Log ("123123" + sktUtility.skeletonAnimation.Skeleton.Slots); // foreach (Slot item in sktUtility.skeletonAnimation.Skeleton.Slots) // { // Debug.Log ("item : " + item.ToString()); // if (item.ToString().Equals("front_bracer")) // { // item.SetColor(new Color(0.0f, 1.0f, 0.0f)); // } // } } }
void Awake() { if (AnimationObj != null) { skeletonAnimation = AnimationObj.GetComponent <SkeletonAnimation>(); render = AnimationObj.GetComponent <Renderer>(); skeletonUtility = AnimationObj.GetComponent <SkeletonUtility>(); } cardInfo = GetComponent <CardInfo>(); //AnimationObj.localEulerAngles = new Vector3(GameManager.instance.cameraAngle, 0, 0); }
void FindRenderer() { if (skeletonRenderer.objectReferenceValue == null) { SkeletonRenderer parentRenderer = SkeletonUtility.GetInParent <SkeletonRenderer>(component.transform); if (parentRenderer != null) { skeletonRenderer.objectReferenceValue = (UnityEngine.Object)parentRenderer; } } }
void OnEnable() { skeletonUtility = GetComponentInParent <SkeletonUtility>(); if (skeletonUtility == null) { return; } skeletonUtility.RegisterBone(this); skeletonUtility.OnReset += HandleOnReset; }
void OnEnable() { skeletonUtility = SkeletonUtility.GetInParent <SkeletonUtility>(transform); if (skeletonUtility == null) { return; } skeletonUtility.RegisterBone(this); skeletonUtility.OnReset += HandleOnReset; }
void OnEnable() { skeletonUtility = GetComponent <SkeletonUtility>(); skeletonRenderer = skeletonUtility.GetComponent <SkeletonRenderer>(); skeleton = skeletonRenderer.Skeleton; if (skeleton == null) { skeletonRenderer.Initialize(false); skeletonRenderer.LateUpdate(); skeleton = skeletonRenderer.skeleton; } }
override public void OnInspectorGUI() { if (needsReset) { component.Reset(); component.DoUpdate(); needsReset = false; SceneView.RepaintAll(); } serializedObject.Update(); // FindRenderer() if (skeletonRenderer.objectReferenceValue == null) { SkeletonRenderer parentRenderer = SkeletonUtility.GetInParent <SkeletonRenderer>(component.transform); if (parentRenderer != null) { skeletonRenderer.objectReferenceValue = (UnityEngine.Object)parentRenderer; } } EditorGUILayout.PropertyField(skeletonRenderer); if (component.valid) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(boneName); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); needsReset = true; serializedObject.Update(); } EditorGUILayout.PropertyField(followBoneRotation); EditorGUILayout.PropertyField(followZPosition); } else { GUILayout.Label("INVALID"); } if (serializedObject.ApplyModifiedProperties() || (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed") ) { component.Reset(); } }
void OnEnable () { skeletonUtility = (SkeletonUtility)target; skeletonRenderer = skeletonUtility.GetComponent<SkeletonRenderer>(); skeleton = skeletonRenderer.skeleton; transform = skeletonRenderer.transform; if (skeleton == null) { skeletonRenderer.Initialize(false); skeletonRenderer.LateUpdate(); skeleton = skeletonRenderer.skeleton; } UpdateAttachments(); isPrefab |= PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab; }
List<Collider> AttachBoundingBoxRagdollColliders (Bone b) { List<Collider> colliders = new List<Collider>(); Transform t = boneTable[b]; GameObject go = t.gameObject; var skin = skeleton.Skin; if (skin == null) skin = skeleton.Data.DefaultSkin; bool flipX = b.WorldFlipX; bool flipY = b.WorldFlipY; List<Attachment> attachments = new List<Attachment>(); foreach (Slot s in skeleton.Slots) { if (s.Bone == b) { skin.FindAttachmentsForSlot(skeleton.Slots.IndexOf(s), attachments); foreach (var a in attachments) { if (a is BoundingBoxAttachment) { if (!a.Name.ToLower().Contains("ragdoll")) continue; var collider = go.AddComponent<BoxCollider>(); var bounds = SkeletonUtility.GetBoundingBoxBounds((BoundingBoxAttachment)a, thickness); collider.center = bounds.center; collider.size = bounds.size; if (flipX || flipY) { Vector3 center = collider.center; if (flipX) center.x *= -1; if (flipY) center.y *= -1; collider.center = center; } colliders.Add(collider); } } } } return colliders; }
public void HandleRebuild(SkeletonRenderer renderer) { if (string.IsNullOrEmpty(slotName)) { return; } ClearColliders(); var skeleton = skeletonRenderer.skeleton; slot = skeleton.FindSlot(slotName); int slotIndex = skeleton.FindSlotIndex(slotName); if (this.gameObject.activeInHierarchy) { foreach (var skin in skeleton.Data.Skins) { var attachmentNames = new List <string>(); skin.FindNamesForSlot(slotIndex, attachmentNames); foreach (var attachmentName in attachmentNames) { var attachment = skin.GetAttachment(slotIndex, attachmentName); var boundingBoxAttachment = attachment as BoundingBoxAttachment; #if UNITY_EDITOR if (attachment != null && boundingBoxAttachment == null) { Debug.Log("BoundingBoxFollower tried to follow a slot that contains non-boundingbox attachments: " + slotName); } #endif if (boundingBoxAttachment != null) { var bbCollider = SkeletonUtility.AddBoundingBoxAsComponent(boundingBoxAttachment, slot, gameObject, true); bbCollider.enabled = true; bbCollider.hideFlags = HideFlags.NotEditable; bbCollider.isTrigger = IsTrigger; currentCollider = bbCollider; } } } } }
void OnEnable() { skeletonUtility = (SkeletonUtility)target; skeletonRenderer = skeletonUtility.GetComponent <SkeletonRenderer>(); skeleton = skeletonRenderer.skeleton; transform = skeletonRenderer.transform; if (skeleton == null) { skeletonRenderer.Initialize(false); skeletonRenderer.LateUpdate(); skeleton = skeletonRenderer.skeleton; } UpdateAttachments(); isPrefab |= PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab; }
void OnEnable () { skeletonUtility = (SkeletonUtility)target; skeletonRenderer = skeletonUtility.GetComponent<SkeletonRenderer>(); skeleton = skeletonRenderer.skeleton; transform = skeletonRenderer.transform; if (skeleton == null) { skeletonRenderer.Reset(); skeletonRenderer.LateUpdate(); skeleton = skeletonRenderer.skeleton; } UpdateAttachments(); if (PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab) isPrefab = true; }
void OnEnable() { skeletonUtility = (SkeletonUtility)target; skeletonRenderer = skeletonUtility.GetComponent <SkeletonRenderer>(); skeleton = skeletonRenderer.Skeleton; if (skeleton == null) { skeletonRenderer.Initialize(false); skeletonRenderer.LateUpdate(); skeleton = skeletonRenderer.skeleton; } if (!skeletonRenderer.valid) { return; } isPrefab |= PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab; }
void EvaluateFlags() { utilityBone = (SkeletonUtilityBone)target; skeletonUtility = utilityBone.skeletonUtility; if (Selection.objects.Length == 1) { containsFollows = utilityBone.mode == SkeletonUtilityBone.Mode.Follow; containsOverrides = utilityBone.mode == SkeletonUtilityBone.Mode.Override; } else { int boneCount = 0; foreach (Object o in Selection.objects) { if (o is GameObject) { GameObject go = (GameObject)o; SkeletonUtilityBone sub = go.GetComponent <SkeletonUtilityBone>(); if (sub != null) { boneCount++; if (sub.mode == SkeletonUtilityBone.Mode.Follow) { containsFollows = true; } if (sub.mode == SkeletonUtilityBone.Mode.Override) { containsOverrides = true; } } } } if (boneCount > 1) { multiObject = true; } } }
static List <Collider2D> AttachBoundingBoxRagdollColliders(Bone b, GameObject go, Skeleton skeleton, float gravityScale) { const string AttachmentNameMarker = "ragdoll"; var colliders = new List <Collider2D>(); var skin = skeleton.Skin ?? skeleton.Data.DefaultSkin; var skinEntries = new List <Skin.SkinEntry>(); foreach (Slot slot in skeleton.Slots) { if (slot.Bone == b) { skin.GetAttachments(skeleton.Slots.IndexOf(slot), skinEntries); bool bbAttachmentAdded = false; foreach (var entry in skinEntries) { var bbAttachment = entry.Attachment as BoundingBoxAttachment; if (bbAttachment != null) { if (!entry.Name.ToLower().Contains(AttachmentNameMarker)) { continue; } bbAttachmentAdded = true; var bbCollider = SkeletonUtility.AddBoundingBoxAsComponent(bbAttachment, slot, go, isTrigger: false); colliders.Add(bbCollider); } } if (bbAttachmentAdded) { SkeletonUtility.AddBoneRigidbody2D(go, isKinematic: false, gravityScale: gravityScale); } } } return(colliders); }
private List <Collider> AttachBoundingBoxRagdollColliders(Bone b) { Skin defaultSkin; List <Collider> list = new List <Collider>(); Transform transform = this.boneTable[b]; GameObject gameObject = transform.gameObject; Skin skin1 = this.skeleton.Skin; if (skin1 != null) { defaultSkin = skin1; } else { defaultSkin = this.skeleton.Data.DefaultSkin; } List <Attachment> attachments = new List <Attachment>(); foreach (Slot slot in this.skeleton.Slots) { if (slot.Bone == b) { defaultSkin.FindAttachmentsForSlot(this.skeleton.Slots.IndexOf(slot), attachments); foreach (Attachment attachment in attachments) { BoundingBoxAttachment boundingBox = attachment as BoundingBoxAttachment; if ((boundingBox != null) && attachment.Name.ToLower().Contains("ragdoll")) { BoxCollider item = gameObject.AddComponent <BoxCollider>(); Bounds boundingBoxBounds = SkeletonUtility.GetBoundingBoxBounds(boundingBox, this.thickness); item.center = boundingBoxBounds.center; item.size = boundingBoxBounds.size; list.Add(item); } } } } return(list); }
List <Collider> AttachBoundingBoxRagdollColliders(Bone b) { const string AttachmentNameMarker = "ragdoll"; var colliders = new List <Collider>(); Transform t = boneTable[b]; GameObject go = t.gameObject; var skin = skeleton.Skin ?? skeleton.Data.DefaultSkin; var skinEntries = new List <Skin.SkinEntry>(); foreach (Slot s in skeleton.Slots) { if (s.Bone == b) { skin.GetAttachments(skeleton.Slots.IndexOf(s), skinEntries); foreach (var entry in skinEntries) { var bbAttachment = entry.Attachment as BoundingBoxAttachment; if (bbAttachment != null) { if (!entry.Name.ToLower().Contains(AttachmentNameMarker)) { continue; } var bbCollider = go.AddComponent <BoxCollider>(); var bounds = SkeletonUtility.GetBoundingBoxBounds(bbAttachment, thickness); bbCollider.center = bounds.center; bbCollider.size = bounds.size; colliders.Add(bbCollider); } } } } return(colliders); }
void OnEnable() { skeletonUtility = (SkeletonUtility)target; skeletonRenderer = skeletonUtility.GetComponent <SkeletonRenderer>(); skeleton = skeletonRenderer.skeleton; transform = skeletonRenderer.transform; if (skeleton == null) { skeletonRenderer.Reset(); skeletonRenderer.LateUpdate(); skeleton = skeletonRenderer.skeleton; } UpdateAttachments(); if (PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab) { isPrefab = true; } }
public void Init() { skeletonUtility = GetComponent <SkeletonUtility>(); skeletonRenderer = skeletonUtility.GetComponent <SkeletonRenderer>(); skeleton = skeletonRenderer.skeleton; Skin defaultSkin = skeleton.Data.DefaultSkin; Skin skin = skeleton.Skin ?? defaultSkin; bool notDefaultSkin = skin != defaultSkin; attachmentTable.Clear(); //Debug.Log(skeleton.Slots.Count); for (int i = skeleton.Slots.Count - 1; i >= 0; i--) { var attachments = new List <Attachment>(); attachmentTable.Add(skeleton.Slots.Items[i], attachments); skin.FindAttachmentsForSlot(i, attachments); // Add skin attachments. if (notDefaultSkin) { defaultSkin.FindAttachmentsForSlot(i, attachments); // Add default skin attachments. } } activeSkin = skeleton.Skin; }
void OnEnable(){ skeletonUtility = GetComponentInParent<SkeletonUtility>(); if(skeletonUtility == null) return; skeletonUtility.RegisterBone(this); skeletonUtility.OnReset += HandleOnReset; }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(mode); if (EditorGUI.EndChangeCheck()) { containsOverrides = mode.enumValueIndex == 1; containsFollows = mode.enumValueIndex == 0; } using (new EditorGUI.DisabledGroupScope(multiObject)) { string str = boneName.stringValue; if (str == "") { str = "<None>"; } if (multiObject) { str = "<Multiple>"; } using (new GUILayout.HorizontalScope()) { EditorGUILayout.PrefixLabel("Bone"); if (GUILayout.Button(str, EditorStyles.popup)) { BoneSelectorContextMenu(str, ((SkeletonUtilityBone)target).hierarchy.skeletonRenderer.skeleton.Bones, "<None>", TargetBoneSelected); } } } EditorGUILayout.PropertyField(zPosition); EditorGUILayout.PropertyField(position); EditorGUILayout.PropertyField(rotation); EditorGUILayout.PropertyField(scale); using (new EditorGUI.DisabledGroupScope(containsFollows)) { EditorGUILayout.PropertyField(overrideAlpha); EditorGUILayout.PropertyField(parentReference); } EditorGUILayout.Space(); using (new GUILayout.HorizontalScope()) { EditorGUILayout.Space(); using (new EditorGUI.DisabledGroupScope(multiObject || !utilityBone.valid || utilityBone.bone == null || utilityBone.bone.Children.Count == 0)) { if (GUILayout.Button(SpineInspectorUtility.TempContent("Add Child Bone", Icons.bone), GUILayout.MinWidth(120), GUILayout.Height(24))) { BoneSelectorContextMenu("", utilityBone.bone.Children, "<Recursively>", SpawnChildBoneSelected); } } using (new EditorGUI.DisabledGroupScope(multiObject || !utilityBone.valid || utilityBone.bone == null || containsOverrides)) { if (GUILayout.Button(SpineInspectorUtility.TempContent("Add Override", Icons.poseBones), GUILayout.MinWidth(120), GUILayout.Height(24))) { SpawnOverride(); } } EditorGUILayout.Space(); } EditorGUILayout.Space(); using (new GUILayout.HorizontalScope()) { EditorGUILayout.Space(); using (new EditorGUI.DisabledGroupScope(multiObject || !utilityBone.valid || !canCreateHingeChain)) { if (GUILayout.Button(SpineInspectorUtility.TempContent("Create 3D Hinge Chain", Icons.hingeChain), GUILayout.MinWidth(120), GUILayout.Height(24))) { CreateHingeChain(); } if (GUILayout.Button(SpineInspectorUtility.TempContent("Create 2D Hinge Chain", Icons.hingeChain), GUILayout.MinWidth(120), GUILayout.Height(24))) { CreateHingeChain2D(); } } EditorGUILayout.Space(); } using (new EditorGUI.DisabledGroupScope(multiObject || boundingBoxTable.Count == 0)) { EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Bounding Boxes", Icons.boundingBox), EditorStyles.boldLabel); foreach (var entry in boundingBoxTable) { Slot slot = entry.Key; var boundingBoxes = entry.Value; EditorGUI.indentLevel++; EditorGUILayout.LabelField(slot.Data.Name); EditorGUI.indentLevel++; { foreach (var box in boundingBoxes) { using (new GUILayout.HorizontalScope()) { GUILayout.Space(30); string buttonLabel = box.IsWeighted() ? box.Name + " (!)" : box.Name; if (GUILayout.Button(buttonLabel, GUILayout.Width(200))) { utilityBone.bone.Skeleton.UpdateWorldTransform(); var bbTransform = utilityBone.transform.Find("[BoundingBox]" + box.Name); // Use FindChild in older versions of Unity. if (bbTransform != null) { var originalCollider = bbTransform.GetComponent <PolygonCollider2D>(); if (originalCollider != null) { SkeletonUtility.SetColliderPointsLocal(originalCollider, slot, box); } else { SkeletonUtility.AddBoundingBoxAsComponent(box, slot, bbTransform.gameObject); } } else { var newPolygonCollider = SkeletonUtility.AddBoundingBoxGameObject(null, box, slot, utilityBone.transform); bbTransform = newPolygonCollider.transform; } EditorGUIUtility.PingObject(bbTransform); } } } } EditorGUI.indentLevel--; EditorGUI.indentLevel--; } } BoneFollowerInspector.RecommendRigidbodyButton(utilityBone); serializedObject.ApplyModifiedProperties(); }
protected virtual void OnEnable () { utilBone = GetComponent<SkeletonUtilityBone>(); skeletonUtility = SkeletonUtility.GetInParent<SkeletonUtility>(transform); skeletonUtility.RegisterConstraint(this); }
protected virtual void OnEnable() { this.utilBone = base.GetComponent <SkeletonUtilityBone>(); this.skeletonUtility = SkeletonUtility.GetInParent <SkeletonUtility>(base.get_transform()); this.skeletonUtility.RegisterConstraint(this); }
public void AddBoundingBox(string skinName, string slotName, string attachmentName) { SkeletonUtility.AddBoundingBox(bone.skeleton, skinName, slotName, attachmentName, transform); }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(mode); if (EditorGUI.EndChangeCheck()) { containsOverrides = mode.enumValueIndex == 1; containsFollows = mode.enumValueIndex == 0; } EditorGUI.BeginDisabledGroup(multiObject); { string str = boneName.stringValue; if (str == "") { str = "<None>"; } if (multiObject) { str = "<Multiple>"; } GUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Bone"); if (GUILayout.Button(str, EditorStyles.popup)) { BoneSelectorContextMenu(str, ((SkeletonUtilityBone)target).skeletonUtility.skeletonRenderer.skeleton.Bones, "<None>", TargetBoneSelected); } GUILayout.EndHorizontal(); } EditorGUI.EndDisabledGroup(); EditorGUILayout.PropertyField(zPosition); EditorGUILayout.PropertyField(position); EditorGUILayout.PropertyField(rotation); EditorGUILayout.PropertyField(scale); // MITCH // EditorGUILayout.PropertyField(flip); EditorGUI.BeginDisabledGroup(containsFollows); { EditorGUILayout.PropertyField(overrideAlpha); EditorGUILayout.PropertyField(parentReference); // MITCH // EditorGUI.BeginDisabledGroup(multiObject || !flip.boolValue); // { // EditorGUI.BeginChangeCheck(); // EditorGUILayout.PropertyField(flipX); // if (EditorGUI.EndChangeCheck()) { // FlipX(flipX.boolValue); // } // } // EditorGUI.EndDisabledGroup(); } EditorGUI.EndDisabledGroup(); EditorGUILayout.Space(); GUILayout.BeginHorizontal(); { EditorGUI.BeginDisabledGroup(multiObject || !utilityBone.valid || utilityBone.bone == null || utilityBone.bone.Children.Count == 0); { if (GUILayout.Button(new GUIContent("Add Child", SpineEditorUtilities.Icons.bone), GUILayout.Width(150), GUILayout.Height(24))) { BoneSelectorContextMenu("", utilityBone.bone.Children, "<Recursively>", SpawnChildBoneSelected); } } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(multiObject || !utilityBone.valid || utilityBone.bone == null || containsOverrides); { if (GUILayout.Button(new GUIContent("Add Override", SpineEditorUtilities.Icons.poseBones), GUILayout.Width(150), GUILayout.Height(24))) { SpawnOverride(); } } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(multiObject || !utilityBone.valid || !canCreateHingeChain); { if (GUILayout.Button(new GUIContent("Create Hinge Chain", SpineEditorUtilities.Icons.hingeChain), GUILayout.Width(150), GUILayout.Height(24))) { CreateHingeChain(); } } EditorGUI.EndDisabledGroup(); } GUILayout.EndHorizontal(); EditorGUI.BeginDisabledGroup(multiObject || boundingBoxTable.Count == 0); EditorGUILayout.LabelField(new GUIContent("Bounding Boxes", SpineEditorUtilities.Icons.boundingBox), EditorStyles.boldLabel); foreach (var entry in boundingBoxTable) { EditorGUI.indentLevel++; EditorGUILayout.LabelField(entry.Key.Data.Name); EditorGUI.indentLevel++; foreach (var box in entry.Value) { GUILayout.BeginHorizontal(); GUILayout.Space(30); if (GUILayout.Button(box.Name, GUILayout.Width(200))) { var child = utilityBone.transform.FindChild("[BoundingBox]" + box.Name); if (child != null) { var originalCollider = child.GetComponent <PolygonCollider2D>(); var updatedCollider = SkeletonUtility.AddBoundingBoxAsComponent(box, child.gameObject, originalCollider.isTrigger); originalCollider.points = updatedCollider.points; if (EditorApplication.isPlaying) { Destroy(updatedCollider); } else { DestroyImmediate(updatedCollider); } } else { utilityBone.AddBoundingBox(currentSkinName, entry.Key.Data.Name, box.Name); } } GUILayout.EndHorizontal(); } } EditorGUI.EndDisabledGroup(); serializedObject.ApplyModifiedProperties(); }
void EvaluateFlags () { utilityBone = (SkeletonUtilityBone)target; skeletonUtility = utilityBone.skeletonUtility; if (Selection.objects.Length == 1) { containsFollows = utilityBone.mode == SkeletonUtilityBone.Mode.Follow; containsOverrides = utilityBone.mode == SkeletonUtilityBone.Mode.Override; } else { int boneCount = 0; foreach (Object o in Selection.objects) { var go = o as GameObject; if (go != null) { SkeletonUtilityBone sub = go.GetComponent<SkeletonUtilityBone>(); if (sub != null) { boneCount++; containsFollows |= (sub.mode == SkeletonUtilityBone.Mode.Follow); containsOverrides |= (sub.mode == SkeletonUtilityBone.Mode.Override); } } } multiObject |= (boneCount > 1); } }