Task Migration
Behavior trees from version 1 of Behavior Designer cannot be migrated to Behavior Designer Pro, but you are able to update your tasks relatively easily. For this lets take a look at the following task from version 1:
using UnityEngine;
using BehaviorDesigner.Runtime;
using BehaviorDesigner.Runtime.Tasks;
using Tooltip = BehaviorDesigner.Runtime.Tasks.TooltipAttribute;
namespace MyNamespace
{
[TaskCategory("Common")]
[TaskIcon("Assets/MyIcon.png")]
[TaskDescription("Logs to the console.")]
public class MyTask : Action
{
[Tooltip("Text to output to the log")]
public SharedString text;
public override TaskStatus OnUpdate()
{
Debug.Log(text.Value);
return TaskStatus.Success;
}
public override void OnReset()
{
// Reset the properties back to their original values
text = "";
}
}
}
The following areas need to be updated in order for this task to be updated for Behavior Designer Pro:
- Namespace Changes: BehaviorDesigner.Runtime no longer exists. We now have:
- Opsive.BehaviorDesigner.Runtime.Tasks: includes the TaskStatus definition.
- Opsive.BehaviorDesigner.Runtime.Tasks.Actions/Conditionals: includes the parent Action or Conditional task.
- Opsive.GraphDesigner.Runtime: Includes the node attributes.
- Opsive.GraphDesigner.Runtime.Variables: Includes the SharedVariable system.
- Updated Attributes: With the Graph Designer separation some attribute names have also been updated:
- TaskIcon: Now called NodeIcon.
- TaskDescription: Now called NodeDescription.
- TaskCategory: Now called Category.
- HelpURL: No longer used.
- Tooltip: Now uses Unity’s Tooltip attribute.
- Shared Variable Changes: Shared Variables can now be generic, meaning defined variables like SharedString are no longer necessary. SharedVariable<string> should now be used.
- OnReset Renaming: Instead of OnReset, we now just have Reset.
With these changes the same task from above is now:
using UnityEngine;
using Opsive.BehaviorDesigner.Runtime.Tasks;
using Opsive.BehaviorDesigner.Runtime.Tasks.Actions;
using Opsive.GraphDesigner.Runtime;
using Opsive.GraphDesigner.Runtime.Variables;
namespace MyNamespace
{
[Opsive.Shared.Utility.Category("Common")]
[NodeIcon("Assets/MyIcon.png")]
[NodeDescription("Logs to the console.")]
public class MyTask : Action
{
[Tooltip("Text to output to the log")]
public SharedVariable<string> text;
public override TaskStatus OnUpdate()
{
Debug.Log(text.Value);
return TaskStatus.Success;
}
public override void Reset()
{
// Reset the properties back to their original values
text = "";
}
}
}