Refactoring Node namespaces without braking the Behavior Tree

FSpitzner

New member
Hi, I've stumbled into a problem. I'm trying to refactor multiple custom nodes I've developed. Specificly I want to change some namespaces around to get the project more orginized. While doing that I've noticed, that every node I'm trying to refactor like that will break inside the trees.
It will show a warning "Unknown Task. Right click and Replace to locate new task."
I can replace the Node, but it will reset all variables previously defined. Are there any ways to refactor namespaces of Nodes without braking their references inside the trees? I basicly want to avoid having to build all the trees that use my nodes from scratch again.
Thanks in advance
 
For me replacing a task after class renaming always keeps variable values. But ofcourse, in a large tree you don't want to do it manually. I tried one thing, and it works.

So, the steps are:
0. MAKE SURE to backup your work.
1. Enable JSON serialization in behavior designer editor preferences.
2. Save scene, so it takes effect.
3. Browse to file location on disk.
4. Open behavior asset with any text editor.
5. Carefully reflect your changes in code by Searching and Replacing namespaces, classes, fields etc.. Save.
6. Go back to Unity and reimport edited behavior assets.
7. Open behavior designer editor, observe changes.
8. Disable JSON serialization, or leave it.

333.PNG
 
Last edited:
Hi again,
sorry for the late response, I was occupied by another Task. I've followed your instructions and was able to refector my Nodes, thank you!
I had a hard time finding my Trees in File though, so I wanted to mention, that if you don't have external Trees you have to go right into the Prefab-Files to find the JSONSerialization. It seems like you have to close down Unity, make all your changes (so refactor your node namespaces and make your changes inside the prefab or external Tree), save and then open up Unity again.
 
  • Like
Reactions: YnS
Top