Need Help Understanding SubScenes

Thanks for that explanation, it was helpful.

I’m still really confused about the entity indexing though.

Quick background - I wanted to use subscenes, but found out that whenever I tried to spawn an entity from prefab at runtime, it would not work in release-build-mode because the resources for the spawned items weren’t loading. So I started using the Addressables package and that worked, although addressables and subscenese don’t play well together because they cause duplicate resources in memory. Recently, I was told that instead of using the Addressables package, I could preload entities in a subscene and make a map of them and then use that map to spawn entities at runtime.

So I made a dummy project and attempted to build such a paradigm, but I am discovering that the entity indexes are nothing like what I expected. In the dummy project, the idea is to simply spawn two different entities periodically.

First of all, during the conversion in the editor, the two entities get stored into the map as index 3 and 4.
8303640--1089213--upload_2022-7-22_14-36-23.png

However, when I look at the DOTS Hierarchy, the two prefab entities are indexed 8 and 10 instead:
8303640--1089216--upload_2022-7-22_14-37-14.png

So I did not expect that. To make it even stranger, after pressing the “Play” button in the editor, the two prefab entity indexes changed yet again to 16 and 13.
8303640--1089219--upload_2022-7-22_14-38-48.png

Well, needless to say, the spawner looks up the ids in the map and tries to clone entity 3 and 4 (which don’t exist) when it really should be cloning 16 and 13.

I put the whole dummy project in a git repo here: https://gitlab.com/lclemens/buggy . Is anyone else doing this type of thing? What am I doing wrong, and why do the entity indexes change during conversion and again after play starts?

1 Like