Log.cs 921 B

1234567891011121314151617181920212223242526272829303132
  1. using UnityEngine;
  2. namespace BehaviorDesigner.Runtime.Tasks
  3. {
  4. [TaskDescription("Log is a simple task which will output the specified text and return success. It can be used for debugging.")]
  5. [TaskIcon("{SkinColor}LogIcon.png")]
  6. public class Log : Action
  7. {
  8. [Tooltip("Text to output to the log")]
  9. public SharedString text;
  10. [Tooltip("Is this text an error?")]
  11. public SharedBool logError;
  12. public override TaskStatus OnUpdate()
  13. {
  14. // Log the text and return success
  15. if (logError.Value) {
  16. Debug.LogError(text);
  17. } else {
  18. Debug.Log(text);
  19. }
  20. return TaskStatus.Success;
  21. }
  22. public override void OnReset()
  23. {
  24. // Reset the properties back to their original values
  25. text = "";
  26. logError = false;
  27. }
  28. }
  29. }