Method FindBehaviorTreeByPath
FindBehaviorTreeByPath(string)
Finds a behavior tree by its path, which can be specified as either an absolute path (e.g., "MyProject/BehaviorTrees/Tree1") or a relative path (e.g., "./Tree1" to find Tree1 in the same directory as the script using this API).
Declaration
IBehaviorTree FindBehaviorTreeByPath(string path)
Parameters
Type | Name | Description |
---|---|---|
string | path | The path of the behavior tree, either absolute or relative. |
Returns
Type | Description |
---|---|
IBehaviorTree | The behavior tree at the specified path, or null if not found. It is important to note that this method could return null if the behavior tree is not located. |
Examples
Using an absolute path:
var behaviorTree = api.FindBehaviorTreeByPath("MyProject/BehaviorTrees/Tree1");
if (behaviorTree != null)
{
Console.WriteLine("Behavior tree found!");
}
else
{
Console.WriteLine("Behavior tree not found.");
}
Using a relative path:
var behaviorTree = api.FindBehaviorTreeByPath("./Tree1");
if (behaviorTree != null)
{
Console.WriteLine("Behavior tree found in the current directory!");
}
else
{
Console.WriteLine("Behavior tree not found in the current directory.");
}