SetActive.cs 803 B

123456789101112131415161718192021222324252627
  1. using UnityEngine;
  2. namespace BehaviorDesigner.Runtime.Tasks.Unity.UnityGameObject
  3. {
  4. [TaskCategory("Unity/GameObject")]
  5. [TaskDescription("Activates/Deactivates the GameObject. Returns Success.")]
  6. public class SetActive : Action
  7. {
  8. [Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")]
  9. public SharedGameObject targetGameObject;
  10. [Tooltip("Active state of the GameObject")]
  11. public SharedBool active;
  12. public override TaskStatus OnUpdate()
  13. {
  14. GetDefaultGameObject(targetGameObject.Value).SetActive(active.Value);
  15. return TaskStatus.Success;
  16. }
  17. public override void OnReset()
  18. {
  19. targetGameObject = null;
  20. active = false;
  21. }
  22. }
  23. }