IndieGame/client/Assets/ParadoxNotion/NodeCanvas/Tasks/Actions/GameObject/RemoveComponent.cs
DOBEST\zhaoyingjie f242607587 初始化工程
2024-10-11 10:12:15 +08:00

35 lines
911 B
C#

using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Actions
{
[Category("GameObject")]
public class RemoveComponent<T> : ActionTask<Transform> where T : Component
{
[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("Remove '{0}'", typeof(T).Name); }
}
protected override void OnExecute() {
var o = agent.GetComponent<T>();
if ( o != null ) {
if ( immediately ) {
Object.DestroyImmediate(o);
} else {
Object.Destroy(o);
}
EndAction(true);
return;
}
EndAction(false);
}
}
}