DestroyImmediate.cs 765 B

12345678910111213141516171819202122232425
  1. using UnityEngine;
  2. namespace BehaviorDesigner.Runtime.Tasks.Unity.UnityGameObject
  3. {
  4. [TaskCategory("Unity/GameObject")]
  5. [TaskDescription("Destorys the specified GameObject immediately. Returns Success.")]
  6. public class DestroyImmediate : Action
  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. var destroyGameObject = GetDefaultGameObject(targetGameObject.Value);
  13. GameObject.DestroyImmediate(destroyGameObject);
  14. return TaskStatus.Success;
  15. }
  16. public override void OnReset()
  17. {
  18. targetGameObject = null;
  19. }
  20. }
  21. }