Search Unity

Can not test a bunch of systems

Discussion in 'Entity Component System' started by dan-kostin, Jan 14, 2019.

  1. dan-kostin

    dan-kostin

    Joined:
    Oct 19, 2018
    Posts:
    22
    I have two ComponentSystems and I need to get the result of their interaction in a test.

    secondSystem.Update(); does not fire onUpdate, because all ComponentGroups are empty. (
    ShouldRunSystem == true <- m_ComponentGroups.IsEmptyIgnoreFilter == true)

    Do you have any suggestions how to update ComponetGroups after the first system update?
     
    Last edited: Jan 14, 2019
  2. dan-kostin

    dan-kostin

    Joined:
    Oct 19, 2018
    Posts:
    22
    "com.unity.entities": "0.0.12-preview.23"
    Situation has not changed.

    Second ComponentSystem always has empty each
    ComponentGroup in Tests with manual Update()
     
  3. dan-kostin

    dan-kostin

    Joined:
    Oct 19, 2018
    Posts:
    22
    Problem was:
    Code (CSharp):
    1. // go instance of GameObject
    2. go.AddComponent<ComponentA>(); // order is important
    3. go.AddComponent<GameObjectEntity>();
    4. // wrong order
    5. // go.AddComponent<ComponentA>();
    6.        
    7. var entity = go.GetComponent<GameObjectEntity>().Entity;
    8.  
    Maybe this will help someone.
     
    Last edited: Jan 27, 2019
  4. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    I encountered this before in my hybrid ECS test. GameObjectEntity captures component on their OnEnable. OnEnable of MonoBehaviour happen instantly on AddComponent and that's why you missed the capture. If you got the wrong order you can disable-enable the game object to clean up and remake the Entity again also.