Search Unity

UpdateInGroup Exception

Discussion in 'Entity Component System' started by JooleanLogic, May 19, 2018.

  1. JooleanLogic

    JooleanLogic

    Joined:
    Mar 1, 2018
    Posts:
    447
    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.

    Code (CSharp):
    1. [UpdateBefore(typeof(UnityEngine.Experimental.PlayerLoop.Update))]
    2. class InputUpdateGroup{}
    3.  
    4. [UpdateInGroup(typeof(InputUpdateGroup))]
    5. class TestSystem : ComponentSystem{}
    It works if I put the UpdateBefore attribute directly on the TestSytem, just not on the group.

    Full stack trace
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. 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)
    3. 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)
    4. 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)
    5. 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)
    6. 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)
    7. 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)
    8. 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)
    9. 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)
     
  2. vanxining

    vanxining

    Joined:
    Mar 29, 2018
    Posts:
    20
    Got the same error.
    Any suggestions?
    Thanks!
     
  3. recursive

    recursive

    Joined:
    Jul 12, 2012
    Posts:
    669
    Same problem here
     
  4. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    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.
     
    recursive and vanxining like this.
  5. JooleanLogic

    JooleanLogic

    Joined:
    Mar 1, 2018
    Posts:
    447
    Great. Thanks Tim.