IsEnabled.cs 941 B

1234567891011121314151617181920212223242526272829
  1. using UnityEngine;
  2. namespace BehaviorDesigner.Runtime.Tasks.Unity.UnityBehaviour
  3. {
  4. [TaskCategory("Unity/Behaviour")]
  5. [TaskDescription("Returns Success if the object is enabled, otherwise Failure.")]
  6. public class IsEnabled : Conditional
  7. {
  8. [Tooltip("The Object to use")]
  9. public SharedObject specifiedObject;
  10. public override TaskStatus OnUpdate()
  11. {
  12. if (specifiedObject == null && !(specifiedObject.Value is UnityEngine.Behaviour)) {
  13. Debug.LogWarning("SpecifiedObject is null or not a subclass of UnityEngine.Behaviour");
  14. return TaskStatus.Failure;
  15. }
  16. return (specifiedObject.Value as Behaviour).enabled ? TaskStatus.Success : TaskStatus.Failure;
  17. }
  18. public override void OnReset()
  19. {
  20. if (specifiedObject != null) {
  21. specifiedObject.Value = null;
  22. }
  23. }
  24. }
  25. }