How does a GhostCollection match ghost types? The GhostCollection docs don’t seem to say. I’m having trouble reverse engineering (or finding) the criteria used for a GhostCollection when matching ghost types. Here’s what I think are the most insightful case, with a vanilla unity project:
I created 3 cube prefabs, each with increasing x scale so I could tell them visually apart. Cube1 has physics components, Cube 2 has a TestComponent with a synchronized [GhostDefaultField], and Cube3 has both. I instantiate all three cubes in succession, in a system:
var ghostCollection = GetSingleton<GhostPrefabCollectionComponent>();
var cube1GhostId = TinyGhostSerializerCollection.FindGhostType<Cube1SnapshotData>();
var cube1Prefab = EntityManager.GetBuffer<GhostPrefabBuffer>(ghostCollection.serverPrefabs)[cube1GhostId].Value;
EntityManager.Instantiate(component.prefabCube1);
However, despite these three entities having different archetypes, a GhostCollection with the prefabs in order – Cube1, Cube2, Cube3 – doesn’t work. All three instantiated cubes are the same (Cube1). However, if I reverse the order – Cube3, Cube2, Cube1 – this works. All three instantiated cubes are different. This begs a few more specific questions:
- Are archetypes used for matching?
- Are components without any GhostDefaultFields checked when matching?
- Are components with GhostDefaultFields checked when matching?