Search Unity

Asset intantiation with Bolt Networking

Discussion in 'Addressables' started by JL_Tech_BBW, Jul 1, 2019.

  1. JL_Tech_BBW

    JL_Tech_BBW

    Joined:
    Jun 22, 2017
    Posts:
    32
    Hello,

    I would like to use the Addressable Asset system with Photon Bolt Networking to create a multiplayer app,
    but both systems are using different Instantiate function.

    Bolt :
    Code (CSharp):
    1. BoltNetwork.Instantiate(PrefabId prefabId);
    Addressable :
    Code (CSharp):
    1. Addressables.InstantiateAsync(IResourceLocation location);
    How can I use both systems together without changing the IInstanceProvider of the Addressable Asset system ?
    Code (CSharp):
    1. public TObject Instantiate<TObject>(TObject source) where TObject : Object
     
  2. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    664
    Pretty sure you'd have to create your own IPrefabPool that uses the addressables system. One issue is that the addressables API is *always* asynchronous and Bolt assumes a synchronous API. That means that you will to call Addressables.LoadAsset to load the prefabs you want to instantiate with Bolt and then instantiate them yourself using the prefab reference itself.
     
  3. JL_Tech_BBW

    JL_Tech_BBW

    Joined:
    Jun 22, 2017
    Posts:
    32
    Thanks,

    I checked the documentation, and this is indeed synchronous.
    https://doc.photonengine.com/en-us/bolt/current/community-wiki/extra-bits/entity-pooling

    The other solution could be to keep the default implementation of Bolt IPrefabPool but to change the code in the Addressable Asset system. (In the InstantiationParameters struct, call the BoltNetwork.Instantiate() instead of the Object.Instantiate() .)

    What are you thinking about ?