I have two scenes set-up as follows:
Scene A |_ ObjectA |_NetworkView (pointing at ScriptA) |_ScriptA Scene B |_ ObjectB |_ NetworkView (pointing at ScriptB) |_ ScriptB
In Scene A I call Object.DontDestroyOnLoad(ObjectA). This prevents the object from being destroyed when I transition to Scene B.
Using ObjectA.networkView.RPC(“SomeMethod”, RPCMode.Others, params) correctly calls the RPC method on all networked clients.
I then transition to scene B and end up with the following set-up:
Scene B |_ Object A |_NetworkView (pointing at Script A) |_Script A |_ Object B |_ NetworkView (pointing at Script B) |_ Script B
Using ObjectA.networkView.RPC(…) still works.
Using ObjectB.networkView.RPC(…) does not work giving the error "RPC call failed because the function ‘ObjectBTest’ does not exist in any script attached to ‘ObjectA’
If I load straight in to Scene B (so I don’t end up with ObjectA) it works correctly.
It looks like Unity3D isn’t ensuring unique NetworkViewIDs across scene changes.
I found the following bug that describes the same problem https://fogbugz.unity3d.com/default.asp?288477_235rid2h but I can’t see what the resolution was.
Am I doing something wrong or do I have to work around this?