除去三大功能外,NodeCanvas 还有一些别的有趣的东西,能帮助我们改进 3 大流程。
# Standalone Action List
给对线添加如上脚本后,我们可以在对象上进行一些可视化的对话构建。
# 自定义 Action 和 Condition
我们可以自定义自己的节点,方便我们在 3 大功能上使用。
生成脚本如下:
using NodeCanvas.Framework; | |
using ParadoxNotion.Design; | |
namespace NodeCanvas.Tasks.Actions{ | |
[Category("my")] | |
[Description("输出一些内容")] | |
public class Mylog : ActionTask{ | |
//Use for initialization. This is called only once in the lifetime of the task. | |
//Return null if init was successfull. Return an error string otherwise | |
protected override string OnInit(){ | |
return null; | |
} | |
//This is called once each time the task is enabled. | |
//Call EndAction() to mark the action as finished, either in success or failure. | |
//EndAction can be called from anywhere. | |
protected override void OnExecute(){ | |
EndAction(true); | |
} | |
//Called once per frame while the action is active. | |
protected override void OnUpdate(){ | |
} | |
//Called when the task is disabled. | |
protected override void OnStop(){ | |
} | |
//Called when the task is paused. | |
protected override void OnPause(){ | |
} | |
} | |
} |
创建之后可以在 Action 中找到:
条件如下:
using NodeCanvas.Framework; | |
using ParadoxNotion.Design; | |
namespace NodeCanvas.Tasks.Conditions{ | |
[Category("my")] | |
[Description("控制条件")] | |
public class myCon : ConditionTask{ | |
//Use for initialization. This is called only once in the lifetime of the task. | |
//Return null if init was successfull. Return an error string otherwise | |
protected override string OnInit(){ | |
return null; | |
} | |
//Called whenever the condition gets enabled. | |
protected override void OnEnable(){ | |
} | |
//Called whenever the condition gets disabled. | |
protected override void OnDisable(){ | |
} | |
//Called once per frame while the condition is active. | |
//Return whether the condition is success or failure. | |
protected override bool OnCheck(){ | |
return true; | |
} | |
} | |
} |
在图中使用:
# 全局黑板
可以在所有图中使用
# 类型管理器
用于管理添加新的数据类型
# 图控制台
# 结构视图
可快速定位到对应节点
# 运行视图
方便在游戏运行中,显示运行的所有树
# 总结
比起另一套行为树插件来说,
NodeCanvas
提供的功能比较基础,其更像是一个程序框架,因此其扩展性也更佳,通过提供的接口和程式,我们可以打造定制化的工作流,代码设计简洁有力。
总之还是非常不错的!😏