Utility Theory Sample: NullReferenceException: Object reference not set to an instance of an object

ruts2020

New member
Hello:

Very interested in the Utility Theory sample. Trying to run and getting this error:

Is there some additional asset I need?

NullReferenceException: Object reference not set to an instance of an object
BinaryDeserialization.LoadTask (BehaviorDesigner.Runtime.TaskSerializationData taskSerializationData, BehaviorDesigner.Runtime.FieldSerializationData fieldSerializationData, System.Collections.Generic.List`1[BehaviorDesigner.Runtime.Tasks.Task]& taskList, BehaviorDesigner.Runtime.BehaviorSource& behaviorSource) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BinaryDeserialization.Load (BehaviorDesigner.Runtime.TaskSerializationData taskData, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.BehaviorSource.CheckForSerialization (System.Boolean force, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.Behavior.CheckForSerialization () (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.Behavior.DrawTaskGizmos (System.Boolean selected) (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
BehaviorDesigner.Runtime.Behavior.OnDrawGizmos () (at <9fd26eacf1af4bd8ab9b56956877bd65>:0)
UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

Thanks!
 
I tried my local version of the sample project and wasn't getting any errors so I just uploaded a fresh version - go ahead and try downloading it again to give it another try.
 
Thanks! This worked great.

Very helpful. Was the Evaluator task there all along or did it come specifically with that example.

What is the best way to nest evaluators in a behavior and manage the evaluators of sub behaviors?
 
The Evaluator came with the sample. The Utility Theory example shows the GetUtility method returning a float value. In most cases you'll need to override GetUtility with your own value depending on the game state.
 
I'm also having problems getting the Utility Theory sample project to run. Even after re-downloading the sample project I get this null reference exception:

NullReferenceException: Object reference not set to an instance of an object
BinaryDeserialization.LoadTask (BehaviorDesigner.Runtime.TaskSerializationData taskSerializationData, BehaviorDesigner.Runtime.FieldSerializationData fieldSerializationData, System.Collections.Generic.List`1[BehaviorDesigner.Runtime.Tasks.Task]& taskList, BehaviorDesigner.Runtime.BehaviorSource& behaviorSource) (at <ee1e067be68b4c178b41d93d93475eae>:0)
BinaryDeserialization.Load (BehaviorDesigner.Runtime.TaskSerializationData taskData, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <ee1e067be68b4c178b41d93d93475eae>:0)
BehaviorDesigner.Runtime.BehaviorSource.CheckForSerialization (System.Boolean force, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <ee1e067be68b4c178b41d93d93475eae>:0)
BehaviorDesigner.Runtime.Behavior.CheckForSerialization () (at <ee1e067be68b4c178b41d93d93475eae>:0)
BehaviorDesigner.Runtime.BehaviorManager.EnableBehavior (BehaviorDesigner.Runtime.Behavior behavior) (at <ee1e067be68b4c178b41d93d93475eae>:0)
BehaviorDesigner.Runtime.Behavior.EnableBehavior () (at <ee1e067be68b4c178b41d93d93475eae>:0)
BehaviorDesigner.Runtime.Behavior.Start () (at <ee1e067be68b4c178b41d93d93475eae>:0)

I'm using Unity 2018.3.0f2, and Windows 10. I tried closing Unity and starting with a clean project but I still run into the same error.

The Ethan character has two Behavior Tree scripts, but neither script seems to have a tree.
 
Ensure that you running version 1.6.1 of Behavior Designer. As a sanity check I also tried the website version in a fresh project and it didn't have any issues.
 
Ensure that you running version 1.6.1 of Behavior Designer. As a sanity check I also tried the website version in a fresh project and it didn't have any issues.
Yes, I'm using version 1.61. (I used the Welcome screen to check.)

I don't even have to hit run to generate errors. As soon as I click on Ethan in the hierarchy I get two errors: a null reference exception, and an argument exception: Getting control 6's position in a group with only 6 controls when doing repaint. Aborting.

The Utility Theory Sample package file is 663.347 bytes, and I downloaded it Jan 26th, 2019.

Here's what I have (don't have) for behavior trees for Ethan.
 

Attachments

  • DecoratorScreenshot.png
    DecoratorScreenshot.png
    786 bytes · Views: 8
  • ActionScreenshot.png
    ActionScreenshot.png
    786 bytes · Views: 8
What version of Unity are you running? That is the correct size of the Unity package.
 
I am just grasping at straws now because I tried a fresh 2018.3 project with a newly downloaded sample project and it worked.

Have you tried clearing your asset store download cache and reimporting Behavior Designer? This will ensure it is getting the Unity 2018.3 version. Also, try to completely remove any utility samples that you have and then download a fresh copy in case you are importing the old version.
 
I tried that with no luck.

After that, I downloaded Unity 2017.4.19f1, and loaded Behavior Designer and the Utility Theory sample scene. It works perfectly! I see there are now several different versions of Unity 2018.3, and that the version I'm running is no longer the most current. Perhaps that's been the problem all along? I'll download 2018.3.3 and try in it.

Thanks for your patience and persistence.
 
It doesn't work in 2018.3.3. Are you using a different version of Unity 2018.3? Could that be it?

[Update] Starting with an empty project still won't work, but starting the project in 2017 and then loading it into 2018 did work. So I have what I need to experiment with the utility function, which is all I wanted.
 
Last edited:
Strange - no, I'm using 2018.3.0. Like you said though you really only need the sample once - after you go through the sample you likely won't look at it again. What is most import is that your trees work in 2018.3.
 
Top