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

26 lines
611 B
C#
Raw 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 GetComponent<T> : ActionTask<Transform> where T : Component
{
[BlackboardOnly]
public BBParameter<T> saveAs;
protected override string info {
get { return string.Format("Get {0} as {1}", typeof(T).Name, saveAs.ToString()); }
}
protected override void OnExecute() {
var o = agent.GetComponent<T>();
saveAs.value = o;
EndAction(o != null);
}
}
}