NodeCanvas扩展

除去三大功能外,NodeCanvas还有一些别的有趣的东西,能帮助我们改进3大流程。

Standalone Action List

image-20210910101555501

给对线添加如上脚本后,我们可以在对象上进行一些可视化的对话构建。

自定义Action和Condition

我们可以自定义自己的节点,方便我们在3大功能上使用。

image-20210910101826535

生成脚本如下:

生成的行为
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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中找到:

image-20210910102308892

条件如下:

生成的条件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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;
}
}
}

在图中使用:

image-20210910102705181

全局黑板

可以在所有图中使用

image-20210910102835494

类型管理器

用于管理添加新的数据类型

image-20210910103000347

图控制台

image-20210910103100590

结构视图

可快速定位到对应节点

image-20210910103148583

运行视图

方便在游戏运行中,显示运行的所有树

image-20210910103307475

总结

比起另一套行为树插件来说,NodeCanvas提供的功能比较基础,其更像是一个程序框架,因此其扩展性也更佳,通过提供的接口和程式,我们可以打造定制化的工作流,代码设计简洁有力。

总之还是非常不错的!😏