Read this document in Chinese: 中文文档
AkiBT is a behavior tree node editor based on UniBT and a large number of modern behavior tree editor functions are enriched.
- Download Release Package
- Using git URL to download package by Unity PackageManager
https://github.com/AkiKurisu/AkiBT.git
- Unity 2021.3 or later.
- Newtonsoft.Json
- Supports constructing behavior tree by visual node editor.
- Support visualizing node status and debugging behavior tree during runtime
- Based on the GraphView framework, it is very convenient to expand the editor and customize new behaviors
- What you see is what you get, all fields are on the graph, this is also the biggest difference between the design of AkiBT and other editors.
-
Open Graph Editor
button opens GraphView for Behavior Tree. -
Finally press save button on tool bar of the editor window. (If invalid node found the color of the node become red.)
-
Run the unity application. you can see node status in the editor window.
- The red node means that last
Update
returnedStatus.Failure
. - The green node means that last
Update
returnedStatus.Success
. - The yellow node means that last
Update
returnedStatus.Running
.
- The red node means that last
-
You can save the GameObject with
AkiBT.BehaviorTreeComponent
as prefab or save to ScriptableObject or save to json file. -
Tutorial Video On BiliBili (The version in video is older and needs to be updated)
AkiBT.BehaviorTree
updates child nodes inUpdate
timing when the UpdateType isUpdateType.Auto
.- If you want to update at any time, change UpdateType to
UpdateType.Manual
and callBehaviorTree.Tick()
; - Only
AkiBT.BehaviorTreeComponent
is theMonoBehavior
. Each node is just a C# Serializable class.
This part will explain the advanced skills and knowledge related to using AkiBT Editor:
You can click on the node Ctrl+C&&Ctrl+V or right-click and select Duplicate to copy the node. You can also batch select to copy and paste.
You can select Copy from Asset
from the upper toolbar, or drag and drop BehaviorTreeAsset
, BehaviorTreeComponent
, or GameObject and Json files that mount BehaviorTreeComponent
into the editor to copy and paste.
SharedVariable can be added in the blackboard.
- For SharedVariable in the field, check
Is Shared
and a drop-down menu will appear for binding shared variables in the behavior tree blackboard.
-
SharedObject supports type restrictions, see SharedVariable for details
-
Double-click the shared variable to modify the name, delete it if it is empty, and update the node field that references the variable after modification.
-
Inspector can modify and delete shared variables
You can set the search mask for the AkiBT editor or other editors inherited from AkiBT in ProjectSetting. You can set the Group type required in the workflow (see above for Group attributes). Nodes without Group attributes will not be filtered.
When open node search window, you can find all BehaviorTreeAsset
in your project and import it to editor view as a subtree.
All shared variables in subtree marked with IsExposed
will be bound to parent behavior tree instance.
If change node class, namespace and assembly, serialization will be broken. Currently, editor will convert them to InvalidNode
and keep their serialized data as string.
This part will explain the advanced skills and knowledge related to using AkiBT's Runtime:
For shared variables across Prefabs in the same scene, you can use SceneVariableScope
(MonoBehaviour) to create Global Variables
that are effective within the scene.
For shared variables across scenes, you can use GameVariableScope
(ScriptableObject) to create Global Variables
that are effective within the application. For packaged games, you need to manually load the ScriptableObject from the resource loading scheme, such as using Resources. Load()
to load
Different scopes can depend on each other. For example, SceneVariableScope
can set GameVariableScope
to ParentScope to obtain global shared variables within the application.
View the field in the Inspector and click Is Global
to mark it. The behavior tree will bind the global shared variable before the shared variable is initialized.
- The button text is green after marking
In a custom node, you can use SharedTObject<T>
to create a generic object (UnityEngine.Object) shared variable. Its binding logic is the same as SharedObject
, as shown in IBindableVariable<T>
, The benefit is that you can have safer type checking
Shared variables can be modified in the Inspector or editor during runtime to debug the behavior tree. Global variables need to be modified in their corresponding scopes.
Using Json serialization in the Editor will save the GUID that refers to the UnityEngine.Object
(hereinafter referred to as UObject) object. However, the UObject object cannot be obtained when Json is deserialized at Runtime. You need to load the required objects in other ways at Runtime. UObject objects, for example, change all references to UObject in the behavior tree to SharedTObject<T>
and SharedObject
, and obtain them from your resource loading scheme through their names at runtime, such as Addressable
resources Address or file path of AssetBundle
.
You can use AkiBTDSL to make it easier to edit the behavior tree at runtime or outside the project. It can be exported to a DSL (domain specific language) format that is easy to read and modify, such as it is convenient to establish unified editing of Excel tables.
The plugin currently has a new User Service (Tools/AkiBT/AkiBT User Service) built in, which provides two functions Serialize Service and Search Service
Since AkiBT uses ScriptableObject for data storage, data loss will occur when modifying the field name of the node (this problem can be avoided by adding FormerlySerializedAsAttribute
to the modified field). However, after modifying the name and namespace of the node, the entire node cannot be deserialized, thus losing all data of the node and subsequent nodes. After serializing to Json, you can use a text editor to modify the nodes in batches, and then re-deserialize to ScriptableObject.
It should be noted that not all fields of ScriptableObject are serialized. Serialize Service only serializes the nodes and shared variables of the behavior tree, and the deserialization is the same.
Select a node type to quickly find all behavior trees using the node, and combine with Serialize Service to find the corresponding Json file at the same time.