EventCallback.cs 491 B

1234567891011121314151617181920212223
  1. using UnityEngine;
  2. using System;
  3. namespace I2.Loc
  4. {
  5. [Serializable]
  6. public class EventCallback
  7. {
  8. public MonoBehaviour Target;
  9. public string MethodName = string.Empty;
  10. public void Execute( UnityEngine.Object Sender = null )
  11. {
  12. if (HasCallback() && Application.isPlaying)
  13. Target.gameObject.SendMessage(MethodName, Sender, SendMessageOptions.DontRequireReceiver);
  14. }
  15. public bool HasCallback()
  16. {
  17. return Target != null && !string.IsNullOrEmpty (MethodName);
  18. }
  19. }
  20. }