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); }
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; }
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); }
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); }