SpriteFactory.SpriteCollider.OnTriggerEnterSprite
C#: void OnTriggerEnterSprite (SpriteFactory.SpriteCollider.CollisionData collisionData)
JS: function OnTriggerEnterSprite (collisionData : SpriteFactory.SpriteCollider.CollisionData) : void
Description
Called when the Collider in collisionData.objectValue enters 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 OnTriggerEnterSprite(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 + " collided with " + otherCollider.name); } } }
JS
// Attach this script to the GameObject that contains your main Sprite component import SpriteFactory; function OnTriggerEnterSprite(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 + " collided with " + otherCollider.name); } }