상속: UnityEngine.MonoBehaviour
        void AddSkin(Skin skin, int slotIndex)
        {
            if (skin == null)
            {
                return;
            }
            var attachmentNames = new List <string>();

            skin.FindNamesForSlot(slotIndex, attachmentNames);

            foreach (var skinKey in attachmentNames)
            {
                var attachment            = skin.GetAttachment(slotIndex, skinKey);
                var boundingBoxAttachment = attachment as BoundingBoxAttachment;

                if (BoundingBoxFollower.DebugMessages && attachment != null && boundingBoxAttachment == null)
                {
                    Debug.Log("BoundingBoxFollower tried to follow a slot that contains non-boundingbox attachments: " + slotName);
                }

                if (boundingBoxAttachment != null)
                {
                    if (!colliderTable.ContainsKey(boundingBoxAttachment))
                    {
                        var bbCollider = SkeletonUtility.AddBoundingBoxAsComponent(boundingBoxAttachment, slot, gameObject, isTrigger);

                        bbCollider.enabled   = false;
                        bbCollider.hideFlags = HideFlags.NotEditable;
                        bbCollider.isTrigger = IsTrigger;
                        colliderTable.Add(boundingBoxAttachment, bbCollider);
                        nameTable.Add(boundingBoxAttachment, skinKey);
                    }
                }
            }
        }
예제 #2
0
 private void AddSkin(Skin skin, int slotIndex)
 {
     if (skin != null)
     {
         List <string> names = new List <string>();
         skin.FindNamesForSlot(slotIndex, names);
         foreach (string str in names)
         {
             Attachment            attachment = skin.GetAttachment(slotIndex, str);
             BoundingBoxAttachment key        = attachment as BoundingBoxAttachment;
             if ((DebugMessages && (attachment != null)) && (key == null))
             {
                 Debug.Log("BoundingBoxFollower tried to follow a slot that contains non-boundingbox attachments: " + this.slotName);
             }
             if ((key != null) && !this.colliderTable.ContainsKey(key))
             {
                 PolygonCollider2D colliderd = SkeletonUtility.AddBoundingBoxAsComponent(key, this.slot, base.gameObject, this.isTrigger, true, 0f);
                 colliderd.enabled   = false;
                 colliderd.hideFlags = HideFlags.NotEditable;
                 colliderd.isTrigger = this.IsTrigger;
                 this.colliderTable.Add(key, colliderd);
                 this.nameTable.Add(key, str);
             }
         }
     }
 }
예제 #3
0
 private void AddSkin(Skin skin, int slotIndex)
 {
     if (skin != null)
     {
         List <string> list = new List <string>();
         skin.FindNamesForSlot(slotIndex, list);
         foreach (string item in list)
         {
             Attachment            attachment            = skin.GetAttachment(slotIndex, item);
             BoundingBoxAttachment boundingBoxAttachment = attachment as BoundingBoxAttachment;
             if (!DebugMessages || attachment == null || boundingBoxAttachment == null)
             {
             }
             if (boundingBoxAttachment != null && !colliderTable.ContainsKey(boundingBoxAttachment))
             {
                 PolygonCollider2D polygonCollider2D = SkeletonUtility.AddBoundingBoxAsComponent(boundingBoxAttachment, slot, base.gameObject, isTrigger);
                 polygonCollider2D.enabled   = false;
                 polygonCollider2D.hideFlags = HideFlags.NotEditable;
                 polygonCollider2D.isTrigger = IsTrigger;
                 colliderTable.Add(boundingBoxAttachment, polygonCollider2D);
                 nameTable.Add(boundingBoxAttachment, item);
             }
         }
     }
 }
예제 #4
0
        public void HandleReset(SkeletonRenderer renderer)
        {
            if (slotName == null || slotName == "")
            {
                return;
            }

            hasReset = true;

            ClearColliders();
            colliderTable.Clear();

            if (skeletonRenderer.skeleton == null)
            {
                skeletonRenderer.OnRebuild -= HandleReset;
                skeletonRenderer.Initialize(false);
                skeletonRenderer.OnRebuild += 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!");
            }
        }
 private void OnEnable()
 {
     this.skeletonUtility = base.transform.GetComponentInParent <SkeletonUtility>();
     if (this.skeletonUtility != null)
     {
         this.skeletonUtility.RegisterBone(this);
         this.skeletonUtility.OnReset += new SkeletonUtility.SkeletonUtilityDelegate(this.HandleOnReset);
     }
 }
		void OnEnable () {
			skeletonUtility = transform.GetComponentInParent<SkeletonUtility>();

			if (skeletonUtility == null)
				return;

			skeletonUtility.RegisterBone(this);
			skeletonUtility.OnReset += HandleOnReset;
		}
예제 #7
0
 private void OnEnable()
 {
     skeletonUtility = base.transform.GetComponentInParent <SkeletonUtility>();
     if (!(skeletonUtility == null))
     {
         skeletonUtility.RegisterBone(this);
         skeletonUtility.OnReset += HandleOnReset;
     }
 }
예제 #8
0
 private void OnEnable()
 {
     this.skeletonUtility = SkeletonUtility.GetInParent <SkeletonUtility>(base.transform);
     if (this.skeletonUtility == null)
     {
         return;
     }
     this.skeletonUtility.RegisterBone(this);
     this.skeletonUtility.OnReset += this.HandleOnReset;
 }
예제 #9
0
        void OnEnable()
        {
            hierarchy = transform.GetComponentInParent <SkeletonUtility>();
            if (hierarchy == null)
            {
                return;
            }

            hierarchy.RegisterBone(this);
            hierarchy.OnReset += HandleOnReset;
        }
예제 #10
0
        void OnEnable()
        {
            skeletonUtility = SkeletonUtility.GetInParent <SkeletonUtility>(transform);

            if (skeletonUtility == null)
            {
                return;
            }

            skeletonUtility.RegisterBone(this);
            skeletonUtility.OnReset += HandleOnReset;
        }
예제 #11
0
        public void HandleRebuild(SkeletonRenderer renderer)
        {
            if (string.IsNullOrEmpty(this.slotName))
            {
                return;
            }
            this.hasReset = true;
            this.ClearColliders();
            this.colliderTable.Clear();
            if (this.skeletonRenderer.skeleton == null)
            {
                SkeletonRenderer skeletonRenderer = this.skeletonRenderer;
                skeletonRenderer.OnRebuild = (SkeletonRenderer.SkeletonRendererDelegate)Delegate.Remove(skeletonRenderer.OnRebuild, new SkeletonRenderer.SkeletonRendererDelegate(this.HandleRebuild));
                this.skeletonRenderer.Initialize(false);
                SkeletonRenderer skeletonRenderer2 = this.skeletonRenderer;
                skeletonRenderer2.OnRebuild = (SkeletonRenderer.SkeletonRendererDelegate)Delegate.Combine(skeletonRenderer2.OnRebuild, new SkeletonRenderer.SkeletonRendererDelegate(this.HandleRebuild));
            }
            Skeleton skeleton = this.skeletonRenderer.skeleton;

            this.slot = skeleton.FindSlot(this.slotName);
            int slotIndex = skeleton.FindSlotIndex(this.slotName);

            if (base.gameObject.activeInHierarchy)
            {
                foreach (Skin skin in skeleton.Data.Skins)
                {
                    List <string> list = new List <string>();
                    skin.FindNamesForSlot(slotIndex, list);
                    foreach (string text in list)
                    {
                        Attachment            attachment            = skin.GetAttachment(slotIndex, text);
                        BoundingBoxAttachment boundingBoxAttachment = attachment as BoundingBoxAttachment;
                        if (boundingBoxAttachment != null)
                        {
                            PolygonCollider2D polygonCollider2D = SkeletonUtility.AddBoundingBoxAsComponent(boundingBoxAttachment, base.gameObject, true);
                            polygonCollider2D.enabled   = false;
                            polygonCollider2D.hideFlags = HideFlags.NotEditable;
                            polygonCollider2D.isTrigger = this.IsTrigger;
                            this.colliderTable.Add(boundingBoxAttachment, polygonCollider2D);
                            this.attachmentNameTable.Add(boundingBoxAttachment, text);
                        }
                    }
                }
            }
        }
        void AddCollidersForSkin(Skin skin, int slotIndex, PolygonCollider2D[] previousColliders, float scale, ref int collidersCount)
        {
            if (skin == null)
            {
                return;
            }
            var skinEntries = new List <Skin.SkinEntry>();

            skin.GetAttachments(slotIndex, skinEntries);

            foreach (var entry in skinEntries)
            {
                var attachment            = skin.GetAttachment(slotIndex, entry.Name);
                var boundingBoxAttachment = attachment as BoundingBoxAttachment;

                if (BoundingBoxFollowerGraphic.DebugMessages && attachment != null && boundingBoxAttachment == null)
                {
                    Debug.Log("BoundingBoxFollowerGraphic tried to follow a slot that contains non-boundingbox attachments: " + slotName);
                }

                if (boundingBoxAttachment != null)
                {
                    if (!colliderTable.ContainsKey(boundingBoxAttachment))
                    {
                        var bbCollider = collidersCount < previousColliders.Length ?
                                         previousColliders[collidersCount] : gameObject.AddComponent <PolygonCollider2D>();
                        ++collidersCount;
                        SkeletonUtility.SetColliderPointsLocal(bbCollider, slot, boundingBoxAttachment, scale);
                        bbCollider.isTrigger       = isTrigger;
                        bbCollider.usedByEffector  = usedByEffector;
                        bbCollider.usedByComposite = usedByComposite;
                        bbCollider.enabled         = false;
                        bbCollider.hideFlags       = HideFlags.NotEditable;
                        colliderTable.Add(boundingBoxAttachment, bbCollider);
                        nameTable.Add(boundingBoxAttachment, entry.Name);
                    }
                }
            }
        }
예제 #13
0
 protected virtual void OnEnable()
 {
     this.utilBone        = base.GetComponent <SkeletonUtilityBone>();
     this.skeletonUtility = SkeletonUtility.GetInParent <SkeletonUtility>(base.transform);
     this.skeletonUtility.RegisterConstraint(this);
 }
		protected virtual void OnEnable () {
			utilBone = GetComponent<SkeletonUtilityBone>();
			skeletonUtility = transform.GetComponentInParent<SkeletonUtility>();
			skeletonUtility.RegisterConstraint(this);
		}
        public void HandleRebuild(SkeletonRenderer renderer)
        {
            if (string.IsNullOrEmpty(slotName))
            {
                return;
            }

            hasReset = true;
            ClearColliders();
            colliderTable.Clear();

            if (skeletonRenderer.skeleton == null)
            {
                skeletonRenderer.OnRebuild -= HandleRebuild;
                skeletonRenderer.Initialize(false);
                skeletonRenderer.OnRebuild += HandleRebuild;
            }

            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.");
                        }
#endif

                        if (boundingBoxAttachment != null)
                        {
                            var bbCollider = SkeletonUtility.AddBoundingBoxAsComponent(boundingBoxAttachment, gameObject, true);
                            bbCollider.enabled   = false;
                            bbCollider.hideFlags = HideFlags.NotEditable;
                            colliderTable.Add(boundingBoxAttachment, bbCollider);
                            attachmentNameTable.Add(boundingBoxAttachment, attachmentName);
                        }
                    }
                }
            }

#if UNITY_EDITOR
            valid = colliderTable.Count != 0;
            if (!valid)
            {
                if (this.gameObject.activeInHierarchy)
                {
                    Debug.LogWarning("Bounding Box Follower not valid! Slot [" + slotName + "] does not contain any Bounding Box Attachments!");
                }
                else
                {
                    Debug.LogWarning("Bounding Box Follower tried to rebuild as a prefab.");
                }
            }
#endif
        }
예제 #16
0
 public void AddBoundingBox(string skinName, string slotName, string attachmentName)
 {
     SkeletonUtility.AddBoneRigidbody2D(transform.gameObject);
     SkeletonUtility.AddBoundingBoxGameObject(bone.skeleton, skinName, slotName, attachmentName, transform);
 }
예제 #17
0
        // MITCH : remove flipX
        //	public void FlipX (bool State) {
        //		if (State != flipX) {
        //			flipX = State;
        //			if (flipX && Mathf.Abs(transform.localRotation.eulerAngles.y) > 90) {
        //				skeletonUtility.skeletonAnimation.LateUpdate();
        //				return;
        //			} else if (!flipX && Mathf.Abs(transform.localRotation.eulerAngles.y) < 90) {
        //				skeletonUtility.skeletonAnimation.LateUpdate();
        //				return;
        //			}
        //		}
        //
        //
        //		bone.FlipX = State;
        //		transform.RotateAround(transform.position, skeletonUtility.transform.up, 180);
        //		Vector3 euler = transform.localRotation.eulerAngles;
        //		euler.x = 0;
        //
        //		euler.y = bone.FlipX ? 180 : 0;
        //        euler.y = 0;
        //		transform.localRotation = Quaternion.Euler(euler);
        //	}

        public void AddBoundingBox(string skinName, string slotName, string attachmentName)
        {
            SkeletonUtility.AddBoundingBox(bone.skeleton, skinName, slotName, attachmentName, transform);
        }
 public void AddBoundingBox(string skinName, string slotName, string attachmentName)
 {
     SkeletonUtility.AddBoundingBoxGameObject(this.bone.skeleton, skinName, slotName, attachmentName, base.transform, true);
 }
예제 #19
0
 protected virtual void OnEnable()
 {
     bone      = GetComponent <SkeletonUtilityBone>();
     hierarchy = transform.GetComponentInParent <SkeletonUtility>();
     hierarchy.RegisterConstraint(this);
 }
예제 #20
0
        /// <summary>
        /// Initialize and instantiate the BoundingBoxFollower colliders. This is method checks if the BoundingBoxFollower has already been initialized for the skeleton instance and slotName and prevents overwriting unless it detects a new setup.</summary>
        public void Initialize()
        {
            if (skeletonRenderer == null)
            {
                return;
            }

            skeletonRenderer.Initialize(false);

            if (string.IsNullOrEmpty(slotName))
            {
                return;
            }

            // Don't reinitialize if the setup did not change.
            if (colliderTable.Count > 0 && slot != null                                 // Slot is set and colliders already populated.
                &&
                skeletonRenderer.skeleton == slot.Skeleton                              // Skeleton object did not change.
                &&
                slotName == slot.data.name                                              // Slot object did not change.
                )
            {
                return;
            }

            DisposeColliders();

            var skeleton = skeletonRenderer.skeleton;

            slot = skeleton.FindSlot(slotName);
            int slotIndex = skeleton.FindSlotIndex(slotName);

            if (slot == null)
            {
                if (BoundingBoxFollower.DebugMessages)
                {
                    Debug.LogWarning(string.Format("Slot '{0}' not found for BoundingBoxFollower on '{1}'. (Previous colliders were disposed.)", slotName, this.gameObject.name));
                }
                return;
            }

            if (this.gameObject.activeInHierarchy)
            {
                foreach (var skin in skeleton.Data.Skins)
                {
                    var attachmentNames = new List <string>();
                    skin.FindNamesForSlot(slotIndex, attachmentNames);

                    foreach (var skinKey in attachmentNames)
                    {
                        var attachment            = skin.GetAttachment(slotIndex, skinKey);
                        var boundingBoxAttachment = attachment as BoundingBoxAttachment;

                        if (BoundingBoxFollower.DebugMessages && attachment != null && boundingBoxAttachment == null)
                        {
                            Debug.Log("BoundingBoxFollower tried to follow a slot that contains non-boundingbox attachments: " + slotName);
                        }

                        if (boundingBoxAttachment != null)
                        {
                            var bbCollider = SkeletonUtility.AddBoundingBoxAsComponent(boundingBoxAttachment, slot, gameObject, isTrigger);
                            bbCollider.enabled   = false;
                            bbCollider.hideFlags = HideFlags.NotEditable;
                            bbCollider.isTrigger = IsTrigger;
                            colliderTable.Add(boundingBoxAttachment, bbCollider);
                            nameTable.Add(boundingBoxAttachment, skinKey);
                        }
                    }
                }
            }

            if (BoundingBoxFollower.DebugMessages)
            {
                bool valid = colliderTable.Count != 0;
                if (!valid)
                {
                    if (this.gameObject.activeInHierarchy)
                    {
                        Debug.LogWarning("Bounding Box Follower not valid! Slot [" + slotName + "] does not contain any Bounding Box Attachments!");
                    }
                    else
                    {
                        Debug.LogWarning("Bounding Box Follower tried to rebuild as a prefab.");
                    }
                }
            }
        }