
The entity already exists for a pre-runtime converted object as well, it's just that the index gets remapped because of the whole subscene instantiation. Or if I were to place everything in the same single subscene that remapping wouldn't really be required in the first place.Ĭlick to expand.See, that's the part that doesn't make sense to me. Or better yet, why doesn't the remapping happen before runtime as well, as all of the needed subscenes are already in my scene? I'm not manually loading in new subscenes during runtime and if I did, I obviously wouldn't be able to reference one of those entities in a component anyways. All the remapping would do is change the entity index, right? Why not just change all references to that index to the same new index, or at the very least have some kind of GetPrimaryEntity that can get the post-conversion index using the old index? That's essentially what I'm doing right now with my own hacky solution. Most importantly, is there any other way to convert an entity before runtime that does allow me to reference it in a MonoBehaviour or are we stuck using the Convert To Entity component for now(which Unity is already saying will be deprecated at some point, and is slower than pre-runtime conversion)?Ĭlick to expand.Fair enough, but why couldn't those references be fixed after the remapping? You can reference an Entity directly for a ConvertToEntity component, even though that has to go through an entire process of conversion first yet that is completely possible. Am I wrong about this? If not, why can't I simply reference an entity in a SubScene the same way I would reference an entity that converts at runtime? I'd actually imagine that would be easier to actually implement as the entity has an index and its components if you convert the entity before runtime (which is why we can inspect the entities with DOTS editor without having to press play), so it wouldn't have to run GetPrimaryEntity on the converted GameObject to get the Entity reference, it would just be able to directly reference it. Currently, a subscene is seemingly the only way to convert an entity before runtime and seems to be used in a way that prefabs currently are (for example, in the megacity demo everything is a subscene IIRC), but I'm not really sure why it wouldn't just be possible to convert a prefab before runtime and just reference the resulting entity the way you would with a GameObject that converts at runtime. I've been trying to get an entity conversion working for a while now, and have had to use pretty dirty/hacky, badly performing solutions to get a reference to an entity within a subscene outside of that subscene (I need an entity reference in a MonoBehaviour).
