Quantcast
Channel: Recent Discussions — Photon Engine
Viewing all articles
Browse latest Browse all 15755

Prefab cache is not assetbundle friendly

$
0
0
Hi,

I currently work on mobile game that is about to be released on iOS and Android and I really enjoy working with PUN.

Although my team and I wanted to share a bug we encounter. We think there is a concept issue about the prefabcache: our game is using Unity's AssetBundle feature to publish new content and so, when a room is filled and an arena ready to start we load the all the prefabs that all players might use during the fight, using :

PhotonNetwork.PrefabCache.Add("myItem", myItem); //myItem is the prefab loaded from an asset bundle

But, by doing that, when Player1 Instantiates "myItem" Player2 is getting a null reference exception.
The reason of that null reference exception is Player1's device is looking for the prefab in PhotonNetwork.PrefabCache. While Player2's device is looking for "myItem" into NetworkingPeer.PrefabCache.

To fix that issue we had two solutions:

Fill NetwokingPeer.PrefabCache the same way we fill PhotonNetwork.PrefabCache or we change the definition of PhotonNetwork.PrefabCache into

public static Dictionary<string, GameObject> PrefabCache
{
get{ return NetworkingPeer.PrefabCache;}
}
We choose the latter and it's working fine, but there is still unecessary checks being done.

It took us quite some time to fully understand the issue and I hope will find this post helpful.


Viewing all articles
Browse latest Browse all 15755

Trending Articles