BUG: External Tree gets copied to prefab

dipyalov

New member
What I do.
- created an empty project with Unity 2019.4.8 and BHD Source Runtime for 2019.3
- created an External Tree with variables
- created a prefab with an empty Behavior Tree
- opened prefab for editing
- assigned the External Tree
- set a variable

Right after I set any variable I get the external tree fully copied to my prefab.

2020-09-22_11-57-53.png

I've managed to hack this behavior by modifying BehaviorSource.cs -> CheckForSerialization

2020-09-22_12-01-37.png

But I'm not sure if this is an intended way of things or a bug. From what I've learned by decompiling Editor DLL - it forces copying of external tree when you assign it in the Inspector.

So please, explain, is this the intended behavior or a bug. The problem is that the trees are getting big and copying external trees to prefabs bloats the game data.
 

Justin

Administrator
Staff member
Thanks - I am planning an update shortly and will take a closer look at this. I'll let you know.
 

Justin

Administrator
Staff member
I am trying to reproduce this but am having a tough time. Here's what I did:

1. Created a new external behavior tree with a variable and some tasks.
2. Created a new prefab with the behavior tree component.
3. Assigned the external tree to the prefab.
4. Inspected the JSON task data. It only serialized the single variable and not the tasks.
5. Change the value of the variable. Only the variables were serialized:
1600991036879.png
1600991018907.png
 

dipyalov

New member
I am trying to reproduce this but am having a tough time. Here's what I did:

1. Created a new external behavior tree with a variable and some tasks.
2. Created a new prefab with the behavior tree component.
3. Assigned the external tree to the prefab.
4. Inspected the JSON task data. It only serialized the single variable and not the tasks.
5. Change the value of the variable. Only the variables were serialized:
View attachment 3961
View attachment 3960

Could there be any difference in codebase we use?
As my debugging has definitely shown that CheckForSerialization was called with external behavior tree as source and that call did all the copying stuff.
Maybe you need to add an assert call for such condition and try playing with variables until it gets called.
 

Justin

Administrator
Staff member
Version 1.6.6 was recently released. Can you try that out? I tried a variety of setups to try to reproduce it but wasn't able to.
 
Top