PhotonView broken inside Unity prefab
I have 1 PhotonView. Using RPCs. When I instantiate it from a prefab, RPCs are broken it's trying to message View Id 0. Intermittent, but mostly broken with exceptions about View id 0 not found.
When I just put it in the scene instead of instantiating from prefab, the RPC calls work fine.
Btw that's cool that you support byte arrays for RPC . thank you :)_
When I just put it in the scene instead of instantiating from prefab, the RPC calls work fine.
Btw that's cool that you support byte arrays for RPC . thank you :)_
0
Comments
I assume you are using UNity 3.4 (and not 3.5).
Then this might possibly fix it:
PhotonViewInspector line +- 75
After applying this patch, make sure to inspect the prefab before using it in your scene.
This works for me on PUN 1.8, but I'm not sure if this'll work out oft he box on 1.7 too.
If the above doesn't work for 1.7, try replacing only SETUP():
I just want to have my multiplayer controller code in a prefab, and not load it unless the user picks multiplayer game. But it's not a big deal to just have it in the scene if PhotonView doesn't like launching from a Prefab.
If you want to use Instantiate at runtime you'll have to allocate PhotonViewID's yourself using PhotonNetwork.AllocateViewID and use that viewID(s) for the new PhotonView(s).
if you can simply leave the prefab in the scene I'd go for that easy route.
You can use Unity's normal Instantiate() to instantiate such a prefab, but the problem is that this will be a user-owned PhotonView (after allocating it a PhotonViewID) and you have no way to send the PhotonViewID to other clients...so communication over this view will not work. You do really need at least 1 scene photonview.
There should be next to no overhead to have a PhotonView in a scene for a non-multiplayer game.