Unity-Technologies/EntityComponentSystemSamples

[Dynamic Asset Bundles // Modding] - 0.51 vs 1.0 - How to load mods into ECS

IliqNikushev opened this issue · 4 comments

Since the removal of GameObjectConversionUtility.ConvertGameObjectHierarchy, i find it difficult to grasp how to load asset bundles in to ECS

The use case that i have is: I have split up the game in multiple asset bundles
A user can add their own prefabs and just need to add the specific behavior it should have
Each of those asset bundles contains prefabs with a unique id
I load them GameObjectConversionUtility.ConvertGameObjectHierarchy, instantiate on demand and just query

a + of having the game into separate asset bundles: if 1 gets updated, only that needs to be downloaded

Now with Entities 1, using Baking, i find it a bit difficult (+ no real documentation) on how to approach the subject, since there is no Runtime conversion

I have already tapped into [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
All the bundles are loaded
But now the ECS needs to be applied
Where / How would be the best way to tap into the resources loaded from that bundle?

I was guessing LoadSceneAsync with the subscenes, but Unity.Scenes.SubScene :: SceneAsset SceneAsset { get; set; } is available only in the Editor and all the documentation i have seen keeps referring to SceneSystem.LoadSceneAsync

AssetBundles are not supported in this flow, essentially content archives need to be built

https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/content-management-create-content-archives.html

Code sample is not working there
1 issue for example: EntitySectionBundlesInBuild is INTERNAL

When following the steps for Build content archives for a specific set of subscenes

  1. it says 'Folder does not exist -ContentUpdate'
  2. There is no feedback if assets publish did anything
  3. I do not see any changes except that there is a folder '-RemoteContent' and only that gets updated

Is an 'ARCHIVE' just a folder structure with catalogs.bin?

I figured out a work-around

  1. Mod.json
  2. Mod.dll
    Mod.dll contains Systems and Component Types
    On startup, inject all component types to the prefabs they should be declared at and load their values from the mod.json
[AttachTo(typeof(Player))
struct PlayerUpgrades : IComponentData {...}
=> attaches to all prefabs that have the Player Component
  • It breaks NetCode, because it relies on Baking, so for that any additional 'sync' mechanism needs to be done through RPC / custom networking