Skip to content

Commit

Permalink
Update API.md
Browse files Browse the repository at this point in the history
  • Loading branch information
AkiKurisu committed Oct 8, 2023
1 parent 69ea9f0 commit 7fff5a9
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 19 deletions.
63 changes: 46 additions & 17 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ public class IsHateGt: Conditional
* Private [SerializeField] field and public field can be set on Behavior Tree editor window.

```c#
[AkiInfo("Composite:随机选择,等待结点结束运行后重新选择")]
[AkiLabel("Random随机选择")]
[AkiInfo("Composite : Random, random update a child and reselect the next node")]
public class Random : Composite
{
private NodeBehavior runningNode;
Expand Down Expand Up @@ -212,8 +211,8 @@ public class Random : Composite
* Private [SerializeField] field and public field can be set on Behavior Tree editor window.

```c#
[AkiInfo("Decorator:子结点返回Success则反转为Failure,为Failure则反转为Successs,返回Running则保持Running")]
[AkiLabel("Invertor反转")]
[AkiInfo("Decorator : If the child node returns Success, it is reversed to Failure," +
" if it is Failure, it is reversed to Success.")]
public class Invertor : Decorator
{
protected override Status OnDecorate(Status childeStatus)
Expand All @@ -230,41 +229,43 @@ public class Invertor : Decorator

## Attributes

1. You can use AkiInfo attribute to describe the behavior detail of the node for information.
1. ``AkiInfo``用以描述结点行为

You can use ``AkiInfo`` attribute to describe the behavior detail of the node for information.
```C#
[AkiInfo("Action:根据isStopped停止NavmeshAgent")]
[AkiInfo("Action : Stop NavmeshAgent according to isStopped")]
public class NavmeshStopAgent : Action
{
private NavMeshAgent _navMeshAgent;
}
```
<img src="Images/InfoAttribute.png" />

1. AkiLabel用以替换编辑器中的结点名称,新版本中你同样可以使用AkiLabel替换编辑器中的字段名称.
2. ``AkiLabel``用以替换编辑器中的结点名称,新版本中你同样可以使用AkiLabel替换编辑器中的字段名称.

AkiLabel attribute is added for replacing label of node's title or field especially for Chinese.
``AkiLabel`` attribute is added for replacing label of node's title or field especially for Chinese.

```C#
[AkiLabel("Navmesh:StopAgent")]
[AkiLabel("Navmesh : StopAgent")]
public class NavmeshStopAgent : Action
{
private NavMeshAgent _navMeshAgent;
[SerializeField,AkiLabel("是否停止")]
[SerializeField,AkiLabel("Whether to stop")]
private SharedBool isStopped;
}
```
<img src="Images/AkiLabel.png" width="480"/>

3. AkiGroup用以对结点进行分类
3. ``AkiGroup``用以对结点进行分类

AkiGroup is an advanced attribute using in Node Searching,you can add this attribute to make it easier and more clear to find certain node.
``AkiGroup`` is an advanced attribute using in Node Searching,you can add this attribute to make it easier and more clear to find certain node.

```c#
[AkiGroup("Animator")]
public class AnimatorSetBool : AnimatorAction
{
}
[AkiGroup("Animator")]
public class AnimatorSetBool : AnimatorAction
{

}
```

<img src="Images/AkiGroup.png" width="480"/>
Expand All @@ -275,6 +276,34 @@ public class NavmeshStopAgent : Action

<img src="Images/SubCategories.png" width="480"/>

4. ``ForceShared``用以强制共享共享变量

``ForceShared`` is used to force shared variables to be shared

```c#
public class SetFloat : Action
{
[SerializeField]
private float setValue;
//Force this variable to be shared
[SerializeField, ForceShared]
private SharedFloat floatToSet;
}
```

5. ``WrapObject``用以显示UIElement不支持显示的对象,将使用IMGUI进行显示

``WrapObject`` is used to display objects that UIElement does not support display, and IMGUI will be used to display them.

```c#
public class InvokeUnityEvent : Action
{
//Use IMGUI to show UnityEvent
[SerializeField, WrapObject]
private UnityEvent unityEvent;
}
```

## SharedVariable

1. 使用共享变量需要在Awake中初始化从而绑定父级行为树中的变量。
Expand Down
1 change: 1 addition & 0 deletions Editor/Core/GraphView/ObjectWrapper/DynamicTypeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Reflection.Emit;
namespace Kurisu.AkiBT.Editor
{
// Code from Unity.Kinematica
internal static class DynamicTypeBuilder
{
const string kDynamicTypeBuilderAssemblyName = "DynamicTypeBuilderAssembly";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using UnityEngine;
namespace Kurisu.AkiBT.Editor
{
// Code from Unity.Kinematica
internal interface IValue
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using UnityEngine;
namespace Kurisu.AkiBT.Editor
{
// Code from Unity.Kinematica
internal static class GenericObjectWrapperHelper
{
public static ScriptableObject Wrap<T>()
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ Modified from [UniBT documentation](https://github.com/yoshidan/UniBT)

<img src="Images/Setting.png" width="480"/>

4. 序列化最佳实践:在Editor中使用Json序列化会保存引用``UnityEngine.Object``(以下简称UObject)对象的GUID,Runtime时Json反序列时无法获取UObject对象,你需要在Runtime通过别的方式加载所需要的UObject对象,例如将行为树中对UObject的引用全部改为SharedTObject和SharedObject,在Runtime通过其名称从你的资源加载方案中获取,例如Addressable的资源地址或AssetBundle的文件路径。
4. Json序列化最佳实践:在Editor中使用Json序列化会保存引用``UnityEngine.Object``(以下简称UObject)对象的GUID,Runtime时Json反序列时无法获取UObject对象,你需要在Runtime通过别的方式加载所需要的UObject对象,例如将行为树中对UObject的引用全部改为SharedTObject和SharedObject,在Runtime通过其名称从你的资源加载方案中获取,例如Addressable的资源地址或AssetBundle的文件路径。

Serialization best practice: Using Json serialization in the Editor will save the GUID that refers to the ``UnityEngine.Object ``(hereinafter referred to as UObject) object. 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 and SharedObject, and obtain them from your resource loading scheme through their names at runtime, such as the resource address of Addressable or the file path of AssetBundle.
Json Serialization best practice: Using Json serialization in the Editor will save the GUID that refers to the ``UnityEngine.Object ``(hereinafter referred to as UObject) object. 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 and SharedObject, and obtain them from your resource loading scheme through their names at runtime, such as the resource address of Addressable or the file path of AssetBundle.

## 拓展功能 Extra Module

Expand Down

0 comments on commit 7fff5a9

Please sign in to comment.