Hello! I discovered some strangeness. If we instantiate the object in the old-fashioned way (UnityEngine.Object) and it has the necessary components, then ComponentSystem correctly finds the corresponding groups of objects (example code below):
public class SomeManager : MonoBehaviour
{
public GameObject prefab;
void DoStuff()
{
Instantiate(prefab);
}
}
public class SomeSystem : ComponentSystem
{
struct SomeGroup
{
public ComponentArray<SomeOldComponent> SomeOldComponent;
public EntityArray Entity;
public int Length;
}
[Inject] SomeGroup someGroup;
protected override void OnUpdate()
{
Debug.Log(someGroup.Length); // <- if "prefab" (higher) has Some Component then Length more than 0
}
}
If we first instantiate an object and then add a component to it, then ComponentSystem does not see this object:
public class SomeManager : MonoBehaviour
{
public GameObject prefab;
void DoStuff()
{
GameObject tmp = Instantiate(prefab);
tmp.AddComponent<SomeOldComponent>();
}
}
public class SomeSystem : ComponentSystem
{
struct SomeGroup
{
public ComponentArray<SomeOldComponent> SomeOldComponent;
public EntityArray Entity;
public int Length;
}
[Inject] SomeGroup someGroup;
protected override void OnUpdate()
{
Debug.Log(someGroup.Length); // <- if "prefab" (higher) hasn't Some Component, and we add them after Instantiate, then Length equal 0
}
}