コード例 #1
0
        private void RemoveCollider(CollisionType from)
        {
            if (from == CollisionType.SpriteRendererAABB)
            {
                if (this.collider != null && this.collider is BoxCollider)
                {
                    if (Application.isPlaying)
                    {
                        Object.DestroyObject(this.collider);
                    }
                    //else
                    //    Object.DestroyImmediate(this.collider);
                }

                if (applyHandler != null)
                {
                    spriteRenderer.applyHandler -= applyHandler;
                    applyHandler = null;
                }
            }

            else if (from == CollisionType.AnimationComponentBB)
            {
                RemoveAllCollider();

                if (applyMultiBoundingHandler != null)
                {
                    spriteAnimation.RemoveComponentUpdateHandler(SpriteAnimationComponentUpdateType.PostUpdateComponent, applyMultiBoundingHandler);
                    applyMultiBoundingHandler = null;
                }
            }
        }
コード例 #2
0
        private void AddCollider(CollisionType to)
        {
            if (to == CollisionType.SpriteRendererAABB)
            {
                if (this.collider == null)
                {
                    gameObject.AddComponent <BoxCollider>();
                }

                if (applyHandler == null)
                {
                    applyHandler = new SpriteRenderer.ApplyHandler(applyBounding);
                }
                spriteRenderer.applyHandler += applyHandler;
            }

            else if (to == CollisionType.AnimationComponentBB)
            {
                BuildCollider();

                if (applyMultiBoundingHandler == null)
                {
                    applyMultiBoundingHandler = new SpriteAnimation.SpriteAnimatonDelegate(applyBounding);
                }
                spriteAnimation.AddComponentUpdateHandler(SpriteAnimationComponentUpdateType.PostUpdateComponent, applyMultiBoundingHandler);
            }
        }
コード例 #3
0
        private void RemoveCollider(CollisionType from)
        {
            if (from == CollisionType.SpriteRendererAABB)
            {
                if (this.collider != null && this.collider is BoxCollider)
                {
                    if (Application.isPlaying)
                        Object.DestroyObject(this.collider);
                    //else
                    //    Object.DestroyImmediate(this.collider);
                }

                if (applyHandler != null)
                {
                    spriteRenderer.applyHandler -= applyHandler;
                    applyHandler = null;
                }
            }

            else if (from == CollisionType.AnimationComponentBB)
            {
                RemoveAllCollider();

                if (applyMultiBoundingHandler != null)
                {
                    spriteAnimation.RemoveComponentUpdateHandler(SpriteAnimationComponentUpdateType.PostUpdateComponent, applyMultiBoundingHandler);
                    applyMultiBoundingHandler = null;
                }
            }
        }
コード例 #4
0
        private void AddCollider(CollisionType to)
        {
            if (to == CollisionType.SpriteRendererAABB)
            {
                if (this.collider == null)
                {
                    gameObject.AddComponent<BoxCollider>();
                }

                if (applyHandler == null)
                {
                    applyHandler = new SpriteRenderer.ApplyHandler(applyBounding);
                }
                spriteRenderer.applyHandler += applyHandler;
            }

            else if (to == CollisionType.AnimationComponentBB)
            {
                BuildCollider();

                if (applyMultiBoundingHandler == null)
                {
                    applyMultiBoundingHandler = new SpriteAnimation.SpriteAnimatonDelegate(applyBounding);
                }
                spriteAnimation.AddComponentUpdateHandler(SpriteAnimationComponentUpdateType.PostUpdateComponent, applyMultiBoundingHandler);
            }
        }