TriggerEventBroadcaster.cs 742 B

12345678910111213141516171819202122232425
  1. using UnityEngine;
  2. using System.Collections;
  3. namespace RootMotion {
  4. /// <summary>
  5. /// Forwards collider OnTrigger.. events.
  6. /// </summary>
  7. public class TriggerEventBroadcaster : MonoBehaviour {
  8. public GameObject target;
  9. void OnTriggerEnter(Collider collider) {
  10. if (target != null) target.SendMessage("OnTriggerEnter", collider, SendMessageOptions.DontRequireReceiver);
  11. }
  12. void OnTriggerStay(Collider collider) {
  13. if (target != null) target.SendMessage("OnTriggerStay", collider, SendMessageOptions.DontRequireReceiver);
  14. }
  15. void OnTriggerExit(Collider collider) {
  16. if (target != null) target.SendMessage("OnTriggerExit", collider, SendMessageOptions.DontRequireReceiver);
  17. }
  18. }
  19. }