Unity Bolt

官网手册:https://ludiq.io/bolt/manual/

Bolt.Addons.Community插件服务于Bolt,使一些使用更加方便:https://github.com/RealityStop/Bolt.Addons.Community/releases 要对应Bolt版本,下载后直接导入,重新Build Unit Options

 

Types:

IconTypeDescription
FloatA number with or without decimal values, like 0.5 or 13.25.
IntegerA number without any decimal value, like 3 or 200.
BooleanA value that can only be either true or false. Commonly used in logic or in toggles.
StringA piece of text, like a name or a message.
CharOne single character in a string, often alphabetic or numeric. Rarely used.
EnumsThere are many enums. Each one is a finite enumeration of options that are often seen in dropdowns.

For example, in Unity, the "Force Mode" enum can be either "Force", "Impulse", "Acceleration" or "Velocity Change".


VectorsVectors represent a set of float coordinates, for example for positions or directions.

There are 3 vectors in Unity:
Vector 2, with X and Y coordinates for 2D;
Vector 3, with X, Y and Z coordinates for 3D;
Vector 4, with X, Y, Z and W coordinates, rarely used.
Game ObjectGame objects are the base entity in Unity scenes. Each game object has a name, a transform for its position and rotation, and a list of components.
ListsA list is an ordered collection of elements. The elements can be of any type, but most often, all elements of a list must be of the same type. You can retrieve and assign each element in a list by its zero-based index (position).
DictionariesA dictionary is a collection in which element has a unique keythat maps to its value. For example, you could have a dictionary of age (integer values) by name (string key). You can retrieve and assign each element by its key.
Object"Object" is a special type. Like we said, every other type is also an object. But when you see, for example, that a node asks for an object, it usually means that it doesn't care about the type of that object.

Variables

IconKindDescription
Flow Variables

Flow variables which are the equivalent to local variables.

一个入口中的局部变量,例如Start,Update,可以理解为对应Start()和Update()函数中的局部变量

Graph Variables

Graph variables are local to an instance of a flow graph. They have the smallest scope and cannot be accessed or modified outside their graph.

整张蓝图中都可以访问该变量

Object Variables

Object variables belong to a game object. They are shared across all graphs on that game object.

属于该Object,挂在该Object上的蓝图都能访问该变量

Scene Variables

Scene variables are shared across the current scene.

在当前场景中共享

Application Variables

Application variables persist even when the scene changes. They will be reset once the application quits.

运行时全局数据存储,应用退出时销毁

Saved Variables

Saved variables will persist even after the application quits. They can be used as a simple but powerful save system. They are saved in Unity's player prefs, which means they unfortunately can't refer to Unity objects like game objects and components.

存在player prefs中,一般放用户设置等记录

嵌入式蓝图和宏蓝图

要在一个GameObject上运行蓝图,必须添加FlowMachine脚本,然后Source选择Embed或Macro

Embed: 嵌入式蓝图,该蓝图嵌入到Machine内部,该GameObject删除,蓝图跟随删除

Macro:就是蓝图类资源,供其他GameObject引用

两者之间可以通过 Convert按钮转换,大部分情况下我们使用Macro

 EmbedMacro
RelationThe graph is embedded in the machine itself.The graph is a macro asset that isreferenced by the machine.
Re-usabilityYou cannot re-use the graph for other machines, but it will be shared across prefab instances.You can re-use the same macro for multiple machines, even if they're not on the same prefab.
PermanenceIf you remove the machine component, the graph will be deleted.
The graph will also be deleted if you switch the Source to Macro.
If you remove the machine component, the macro asset will still exist.
The graph will notbe deleted if you switch the Source to Embed.
Scene ReferenceThe graph can refer to game objects from the current scene in its graph, as long as it's not saved as a prefab.The graph cannot refer to game objects from the current scene, because it does not "belong" to any scene.
PrefabsThe machine should not be used if you instantiate your prefab while in the editor.The machine can safely be used on all prefabs.

Group

按住Ctrl,点击鼠标左键选中一片区域,区域中的所有节点就被划分到该组,主要是为了组织节点,清晰划分

Custom Units

 

 

 

using System;
using Ludiq; 
using Bolt; 
[TypeIcon(typeof(GetGraphVariable))] 
[UnitOrder(0)] 
[UnitSurtitle("Sur Title")] 
[UnitSubtitle("Sub Title")] 
[UnitShortTitle("Short Title")] 
[UnitTitle("Title")] 
[UnitCategory("MyUnits")] //类似于文件夹指定 “Folder/SubFolder/SubSubFolder” 
public class InOutUnit : Unit

{

    [DoNotSerialize]

    public ControlInput input { get; private set; }

    [DoNotSerialize]

    public ControlOutput output { get; private set; }

    [DoNotSerialize]

    public ValueInput valueIn { get; private set; }

    [DoNotSerialize]

    public ValueOutput valueOut { get; private set; }

    protected override void Definition()

    {

        input = ControlInput("in", Enter);

        output = ControlOutput("output");

        valueIn = ValueInput<float>("valueIn");

        valueOut = ValueOutput<float>("valueOut", ReturnFloat);

        Requirement(valueIn, valueOut);

    }



    public ControlOutput Enter(Flow flow)

    {

        return output;

    }

    public float ReturnFloat(Flow flow)

    {

        return flow.GetValue<float>(valueIn);    

    }

}

执行 Tools->Bolt->Build Unit Options,重新生成节点数据库:Assets/Ludiq/Bolt.Flow/Generated/UnitOptions.db

蓝图中的节点、顺序等关系以json格式记录在该Macro资源或perfab中(Embed)

在对节点进行修改后,不用再次Build,只需要 Tools->Bolt->Update Unit Options

可以开启自动更新,Tools -> Ludiq -> Configuration

 

 

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值