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