SpriteFactory.SpriteCollider.OnTriggerExitSprite
C#: void OnTriggerExitSprite (SpriteFactory.SpriteCollider.CollisionData collisionData)
JS: function OnTriggerExitSprite (collisionData : SpriteFactory.SpriteCollider.CollisionData) : void
Description
Called when the Collider in collisionData.objectValue has stopped touching the trigger. This message is sent to all component siblings of the Sprite which owns this SpriteCollider.
The collisionData object contains information about the collision:
If the collision was between 3D colliders, the collisionData.objectValue field contains a Collider object, which is the collider that entered the trigger.
If the collision was between 2D colliders, the collisionData.objectValue field contains a Collider2D object, which is the collider that entered the trigger.
Note that trigger events are only sent if one of the colliders also has a rigidbody attached.
Example:
C#
// Attach this script to the GameObject that contains your main Sprite component using UnityEngine; using System.Collections; using SpriteFactory; public class CollisionTest : MonoBehaviour { void OnTriggerExitSprite(SpriteFactory.SpriteCollider.CollisionData collisionData) { if(collisionData.spriteColliderName == "HitCollider") { // test collider name to determine which responded Collider otherCollider = (Collider)collisionData.objectValue; // get the collider that collided with this from collisionData Debug.Log(collisionData.spriteColliderName + " exited collision with " + otherCollider.name); } } }
JS
// Attach this script to the GameObject that contains your main Sprite component import SpriteFactory; function OnTriggerExitSprite(collisionData : SpriteFactory.SpriteCollider.CollisionData) : void { if(collisionData.spriteColliderName == "HitCollider") { // test collider name to determine which responded var otherCollider : Collider = collisionData.objectValue; // get the collider that collided with this from collisionData Debug.Log(collisionData.spriteColliderName + " exited collision with " + otherCollider.name); } }