I have a prefab inside an assetBundle that im trying to instantiate using PhotonNetwork.InstantiateSceneObject

How do I use PhotonNetwork.InstantiateSceneObject to instantiate a prefab that is inside an asset bundle?

For example here is existing code:

AssetBundle ab=AssetBundle.LoadFromFile("c:\assets\");
var prefab=ab.LoadAsset("networked_monster.prefab");




  • Hi,

    I am assuming you are on PUN 2./

    Pun usually load network prefabs by the name of the prefab, which must be in a Resources folder.

    So in this case I don't think it will work, unless asset bundles can generate content to be inside a Resources folder. in which case it's fine.

    otherwise, you'll need to implement the IPunPrefabPool interface and then you can decide how to instantiate the prefab and where you can get it.

    Please check the default implementation ( DefaultPool class in punclasses.cs) for an example.


Sign In or Register to comment.