SendMessage.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. using UnityEngine;
  2. namespace BehaviorDesigner.Runtime.Tasks.Unity.UnityGameObject
  3. {
  4. [TaskCategory("Unity/GameObject")]
  5. [TaskDescription("Sends a message to the target GameObject. Returns Success.")]
  6. public class SendMessage : Action
  7. {
  8. [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")]
  9. public SharedGameObject targetGameObject;
  10. [Tooltip("The message to send")]
  11. public SharedString message;
  12. [Tooltip("The value to send")]
  13. public SharedGenericVariable value;
  14. public override TaskStatus OnUpdate()
  15. {
  16. if (value.Value != null) {
  17. GetDefaultGameObject(targetGameObject.Value).SendMessage(message.Value, value.Value.value.GetValue());
  18. } else {
  19. GetDefaultGameObject(targetGameObject.Value).SendMessage(message.Value);
  20. }
  21. return TaskStatus.Success;
  22. }
  23. public override void OnReset()
  24. {
  25. targetGameObject = null;
  26. message = "";
  27. }
  28. }
  29. }