EventCallback.cs 514 B

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