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

45 lines
1.4 KiB
C#

using NodeCanvas.Framework;
using NodeCanvas.Framework.Internal;
using ParadoxNotion.Design;
using UnityEngine;
namespace NodeCanvas.Tasks.Actions
{
[Category("✫ Blackboard")]
[Description("Use this to set a variable on any blackboard by overriding the agent")]
public class SetOtherBlackboardVariable : ActionTask<Blackboard>
{
[RequiredField]
public BBParameter<string> targetVariableName;
public BBObjectParameter newValue;
protected override string info {
get { return string.Format("<b>{0}</b> = {1}", targetVariableName.ToString(), newValue != null ? newValue.ToString() : ""); }
}
protected override void OnExecute() {
agent.SetVariableValue(targetVariableName.value, newValue.value);
EndAction();
}
///----------------------------------------------------------------------------------------------
///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
protected override void OnTaskInspectorGUI() {
if ( GUILayout.Button("Select Target Variable Type") ) {
EditorUtils.ShowPreferedTypesSelectionMenu(typeof(object), (t) => { newValue.SetType(t); });
}
if ( newValue.varType != typeof(object) ) {
DrawDefaultInspector();
}
}
#endif
}
}