Hello!
How can I load entity from resource folder on runtime?(or get entity prefab by string) It isn’t clear for me about baking process, but everyone talks about it.
I have json configs and must spawn items by string!
In GameObject World, i just write Resources.Load(%path to prefab%) and get my prefab.
I don’t understand, how to load prefab in dots(or bake)
Please, explain new resource load pipeline to me!
You can read about baking here in docs.
There is no built-in solution of loading entity as is like loading gameobject. But before 1.0 there was runtime convertion (without subscenes), so you could load your gameobject prefab with ConvertToEntity component attached, instantiate it on scene, and then runtime convertion would do all for you. Actually some devs use it in similar way to implement addressables entities.
Though after 1.0 there is no more runtime convertion. Instead of this we have baking process which only works in unity and only with subscenes, so in build you load serialized binary data instead of having any convertion process every time you starting your app.
As I understand there is several ways of how you can spawn things from JSON config like you’ve mentioned.
- Don’t use 1.0, instead use lower versions. Though you lost new API, and in my opinion baking is better then old convertion. So using 0.51 and lower you can still use runtime convertion.
- Load your unity object (ScriptableObject for example) then construct entity at runtime setting it’s data through
EntityManager. You can even recreate whole runtime convertion by yourself, all this time it was just gameobject + mono-components → entity + ecs-components.
- Split your loadable prefabs by several subscenes, have link to subscene by it’s GUID. Load needed subscene when you need. This is how you can have loadable entities.
This isn’t the first time when dev looking for a way to load entity, so probably in some future we will see entity prefab like gameobject prefab.
Hello, for explaination on the baking workflow, in addition to the documentation and the Entiteis tutorial, you can have a look at my video on the subject :
For loading entities from the ressources, you can refer to the documentation on Content Management :
An the sample that was available in hte exp vesion of ECS :
Although, the fact that the sample was removed from the repodistory when they updated it to preview 15 tells me that, there will probably be sufficient changes to the way it works for the sample to no longer be relevent when they “advertise” it.
So I would take that content management API with a grain of salt.