GetIsEnabled.cs 1.1 KB

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