SpriteFactory.SpriteCollider.OnTriggerStaySprite
C#: void OnTriggerStaySprite (SpriteFactory.SpriteCollider.CollisionData collisionData)
JS: function OnTriggerStaySprite (collisionData : SpriteFactory.SpriteCollider.CollisionData) : void
Description
Called almost all the frames for every Collider in collisionData.objectValue that is 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 OnTriggerStaySprite(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 + " continued colliding with " + otherCollider.name); } } }
JS
// Attach this script to the GameObject that contains your main Sprite component import SpriteFactory; function OnTriggerStaySprite(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 + " continued colliding with " + otherCollider.name); } }