Description
Please explain the suggested feature in detail.
Addressables allows prefabs to be loaded from asset bundles at runtime. Prefabs are normally spawned via
Addressables.InstantiateAsync("AssetAddress");
or
Addressables.LoadAssetAsync<GameObject>("AssetAddress");
Both of these methods are asynchronous and have a completed event when they are finished.
How exactly does this keep you from releasing your game right now?
With the current spawn handlers within mirror it is not possible to call these methods as the handlers return a result right away.
The alternative is to list the prefab early to make sure they exist by the time mirror wants to spawn them, this reducing some of the benefits of being able to load and unload assets when they are needed.
Can you suggest a possible solution?
Add another version of the spawnHandlers
that does not return the game object right away, but instead passes a callback into the handler. That callback would then be called by the user's handler after InstantiateAsync
has finished. The callback would then apply the spawn message.
One possible problem with this may be future messages being received on the client before they have finished loading the prefab. We may need to add a way to queue up messages for a netId and apply them after the callback is called.