IndieGame/client/Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/GameObject/DestroyGameObject.cs

30 lines
775 B
C#
Raw Permalink Normal View History

2024-10-11 10:12:15 +08:00
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Actions
{
[Category("GameObject")]
public class DestroyGameObject : ActionTask<Transform>
{
[Tooltip("DestroyImmediately is recomended if you are destroying objects in use of the framework.")]
public bool immediately;
protected override string info {
get { return string.Format("Destroy {0}", agentInfo); }
}
//in case it destroys self
protected override void OnUpdate() {
if ( immediately ) {
Object.DestroyImmediate(agent.gameObject);
} else {
Object.Destroy(agent.gameObject);
}
EndAction();
}
}
}