UpdateInGroup Exception

I get a NullReferenceException whenever I use UpdateBefore on a group. I get the exception no matter what PlayerLoop phase I choose. It works fine if I use UpdateAfter though. Not sure where I’m going wrong.

[UpdateBefore(typeof(UnityEngine.Experimental.PlayerLoop.Update))]
class InputUpdateGroup{}

[UpdateInGroup(typeof(InputUpdateGroup))]
class TestSystem : ComponentSystem{}

It works if I put the UpdateBefore attribute directly on the TestSytem, just not on the group.

Full stack trace

NullReferenceException: Object reference not set to an instance of an object
Unity.Entities.ScriptBehaviourUpdateOrder+ScriptBehaviourGroup..ctor (System.Type grpType, System.Collections.Generic.IDictionary`2[TKey,TValue] allGroups, System.Collections.Generic.HashSet`1[T] circularCheck) (at C:/ProgramData/Unity/cache/packages/staging-packages.unity.com/com.unity.entities@0.0.11/Unity.Entities/ScriptBehaviourUpdateOrder.cs:87)
Unity.Entities.ScriptBehaviourUpdateOrder.CollectGroups (System.Collections.Generic.IEnumerable`1[T] activeManagers, System.Collections.Generic.Dictionary`2[System.Type,Unity.Entities.ScriptBehaviourUpdateOrder+ScriptBehaviourGroup]& allGroups, System.Collections.Generic.Dictionary`2[System.Type,Unity.Entities.ScriptBehaviourUpdateOrder+DependantBehavior]& dependencies) (at C:/ProgramData/Unity/cache/packages/staging-packages.unity.com/com.unity.entities@0.0.11/Unity.Entities/ScriptBehaviourUpdateOrder.cs:345)
Unity.Entities.ScriptBehaviourUpdateOrder.BuildSystemGraph (System.Collections.Generic.IEnumerable`1[T] activeManagers, UnityEngine.Experimental.LowLevel.PlayerLoopSystem defaultPlayerLoop) (at C:/ProgramData/Unity/cache/packages/staging-packages.unity.com/com.unity.entities@0.0.11/Unity.Entities/ScriptBehaviourUpdateOrder.cs:359)
Unity.Entities.ScriptBehaviourUpdateOrder.CreateSystemDependencyList (System.Collections.Generic.IEnumerable`1[T] activeManagers, UnityEngine.Experimental.LowLevel.PlayerLoopSystem defaultPlayerLoop) (at C:/ProgramData/Unity/cache/packages/staging-packages.unity.com/com.unity.entities@0.0.11/Unity.Entities/ScriptBehaviourUpdateOrder.cs:578)
Unity.Entities.ScriptBehaviourUpdateOrder.InsertWorldManagersInPlayerLoop (UnityEngine.Experimental.LowLevel.PlayerLoopSystem defaultPlayerLoop, Unity.Entities.World[] worlds) (at C:/ProgramData/Unity/cache/packages/staging-packages.unity.com/com.unity.entities@0.0.11/Unity.Entities/ScriptBehaviourUpdateOrder.cs:562)
Unity.Entities.ScriptBehaviourUpdateOrder.UpdatePlayerLoop (Unity.Entities.World[] worlds) (at C:/ProgramData/Unity/cache/packages/staging-packages.unity.com/com.unity.entities@0.0.11/Unity.Entities/ScriptBehaviourUpdateOrder.cs:810)
Unity.Entities.DefaultWorldInitialization.Initialize (System.String worldName, System.Boolean editorWorld) (at C:/ProgramData/Unity/cache/packages/staging-packages.unity.com/com.unity.entities@0.0.11/Unity.Entities.Hybrid/Injection/DefaultWorldInitialization.cs:58)
Unity.Entities.AutomaticWorldBootstrap.Initialize () (at C:/ProgramData/Unity/cache/packages/staging-packages.unity.com/com.unity.entities@0.0.11/Unity.Entities.Hybrid/Injection/AutomaticWorldBootstrap.cs:11)

Got the same error.
Any suggestions?
Thanks!

Same problem here

Based on the callstack it looks like a bug we fixed recently, the fix should be out in the next version of the ECS package. Specifically the code got confused about UpdateBeforeAttribute / UpdateAfterAttribute in the ScriptBehaviourGroup constructor.

2 Likes

Great. Thanks Tim.