- Home /
PlayerPrefs and NetworkView problems
I'm trying to access a variable from PlayerPrefs and send it to the network, but something weird is happening. The object which this script is attached to contains a NetworkView component.
When I try to get some variable from PlayerPrefs, it doesn't show my variable, but it shows the variable of another player connected to the server.
This is similiar to what I'm trying to do:
Calling the RPC:
networkView.RPC("showMyName", RPCMode.All, PlayerPrefs.GetString("myname"));
The RPC:
@RPC
function showMyName( name : String )
{
print(name);
}
The result is not the "myname" sent by the player, but some "myname" of some other player in the network, probably the last one who connected.
What is calling that RPC function and when? The server? A client?
Answer by ramonfr · Jul 15, 2012 at 01:39 AM
Ok, the problem is solved.
I was running two Windows builds at once. So, they were sharing the same variable and path, which was stored in the Windows registry.
If I run one build for web player and another for Windows, it' alright, because the PlayerPrefs are stored in different paths.
Answer by rkstormer · Sep 23, 2014 at 12:59 PM
It is related to running multiple instances on one Windows computer and the fact that the PlayerPrefs are stored in the common registry on Windows, as ramonfr said.
I was able to get around it by changing the "Product Name" in the player setting when I built the Windows app. If each instance you run has a unique product name then it will work correctly.
Your answer
Follow this Question
Related Questions
PlayerPrefs and Multiplayer 0 Answers
Network Game: Pickups for certain player 0 Answers
Unity Networking. Player flickers. 0 Answers
Can I delay the instantiation of the network objects? 1 Answer