luis-l / BonsaiBehaviourTree

An advanced behaviour tree solution for the Unity game engine
MIT License
417 stars 45 forks source link

The object you want to instantiate is null #19

Closed vincentaber closed 3 years ago

vincentaber commented 3 years ago

After restarting a scene where I had built two trees with custom nodes, one of them doesn't work anymore. Upon Entering Play Mode I get this error : ArgumentException: The Object you want to instantiate is null. UnityEngine.Object.CheckNullArgument (System.Object arg, System.String message) (at <29ad182faa3f478c9310d6a2e7143c15>:0) UnityEngine.Object.Instantiate[T] (T original) (at <29ad182faa3f478c9310d6a2e7143c15>:0) Bonsai.Core.BehaviourTree+<>c.b__39_0 (Bonsai.Core.BehaviourNode n) (at Assets/BonsaiBehaviourTree/Core/BehaviourTree.cs:340) System.Linq.Enumerable+SelectArrayIterator2[TSource,TResult].ToArray () (at <351e49e2a5bf4fd6beabb458ce2255f3>:0) System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable1[T] source) (at <351e49e2a5bf4fd6beabb458ce2255f3>:0) Bonsai.Core.BehaviourTree.SetNodes (System.Collections.Generic.IEnumerable`1[T] nodes) (at Assets/BonsaiBehaviourTree/Core/BehaviourTree.cs:118) Bonsai.Core.BehaviourTree.Clone (Bonsai.Core.BehaviourTree sourceTree) (at Assets/BonsaiBehaviourTree/Core/BehaviourTree.cs:340) Bonsai.Core.BonsaiTreeComponent.Awake () (at Assets/BonsaiBehaviourTree/Core/BonsaiTreeComponent.cs:22) UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at <7d90b28560b644ce87b8263efcc36eed>:0) UnityEditor.HostView.Invoke (System.String methodName) (at <7d90b28560b644ce87b8263efcc36eed>:0) UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at <7d90b28560b644ce87b8263efcc36eed>:0) UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at <7d90b28560b644ce87b8263efcc36eed>:0) UnityEditor.DockArea.OldOnGUI () (at <7d90b28560b644ce87b8263efcc36eed>:0) UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <06214b245dbb4d10a9cefd10639bb04e>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

It's quite annoying because there was quite a lot of work there, and now I can't even open the graph. I don't know if this because of some nodes I made, but it worked perfectly when I closed Unity a few hours ago...

luis-l commented 3 years ago

Thanks for the report.

Could you show the general outline of your Custom node classes? This could help me track down the error quicker.

vincentaber commented 3 years ago

Actually I'm pretty sure it was my fault, I tried to be clever and make all the node classes in one file, but I think Bonsai didn't like that (I did get a warning message but I noticed it too late). I think I can close the issue, and if I run again into something similar I'll post the nodes.