In this sample, you can download all content and load any Entity Prefab or Entity Scene.
ECS Content Management System manual: https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/content-management-delivery.html
- Import project with Unity 2022.3 or up
- Build remote content to delivery: Tools > Build Content
- Copy the remote content to your favourite HTTP server, for example, nginx
- Open SampleScene.scene, find the GameObject UIManager, change the url to your download server
- Build the application to test. It works in the editor. However it is better to test in the production build, Unity do a lot of tricks that only works in editor.
Your will see the above screen in the sample. Here is the detail:
-
Init with all
Initialize and download all contents from the server. And you can load them using the button on the right.
-
Init empty
Bugged or ambiguous behaviour, will by explained below.
-
Delete content cache
Delete all content cache
-
Load Cube Prefab , Load Capsule Prefab, Load Cylinder Scene, Load Capsule Scene
Load entity prefabs or scenes. Do it after init.
When initializing the content system, RuntimeContentSystem.LoadContentCatalog is called with a initialContentSet. With the initialContentSet, contents of the ContentSet is downloaded when the content system is initializing. I cannot find other method to download contents after initialization, unless we do some hack to the internal system. Everything works fine, when we use all as the initialContentSet. That means downloading all assets when the system is initializing. However, in a proper use case of a content distribution system, like Addressable and Asset Bundles, we are not going to download all assets at the beginning. Instead, we want to download the assets on demand, when it is needed only. We can do that in Addressable and Asset Bundles.
In Content Management System, we can do it with a broken way. We have to restart the application for 3 or more times. Keep rebooting the application, initialize content system with empty content set, and load the desired prefab or scene, reboot again if the asset is not loaded.
Here is the detail explained:
- Launch the application, and initialize content system with empty content set. Content catalog is downloaded. Load the desired prefab or scene, it is downloaded. But the system cannot actually load the asset and stucked.
- Reboot the application, and initialize content system with empty content set. Some dependency is downloaded. Load the desired prefab or scene again, its dependencies is downloaded, but the system is still stucked and failed to load.
- Reboot the application, and initialize content system with empty content set. Load the desired prefab or scene again, if all dependencies is downloaded, it can be loaded successfully. If not, go to Step 2, to download any dependencies of dependencies.