ActiveSelf.cs 717 B

12345678910111213141516171819202122
  1. using UnityEngine;
  2. namespace BehaviorDesigner.Runtime.Tasks.Unity.UnityGameObject
  3. {
  4. [TaskCategory("Unity/GameObject")]
  5. [TaskDescription("Returns Success if the GameObject is active in the hierarchy, otherwise Failure.")]
  6. public class ActiveSelf : Conditional
  7. {
  8. [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")]
  9. public SharedGameObject targetGameObject;
  10. public override TaskStatus OnUpdate()
  11. {
  12. return GetDefaultGameObject(targetGameObject.Value).activeSelf ? TaskStatus.Success : TaskStatus.Failure;
  13. }
  14. public override void OnReset()
  15. {
  16. targetGameObject = null;
  17. }
  18. }
  19. }