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

44 lines
928 B
C#

using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Actions
{
[Name("Set Enabled")]
[Category("GameObject")]
[Description("Set the monobehaviour's enabled state.")]
public class SetObjectEnabled : ActionTask<MonoBehaviour>
{
public enum SetEnableMode
{
Disable = 0,
Enable = 1,
Toggle = 2
}
public SetEnableMode setTo = SetEnableMode.Toggle;
protected override string info {
get { return string.Format("{0} {1}", setTo, agentInfo); }
}
protected override void OnExecute() {
bool value;
if ( setTo == SetEnableMode.Toggle ) {
value = !agent.enabled;
} else {
value = (int)setTo == 1;
}
agent.enabled = value;
EndAction();
}
}
}