- Home /
Playerprefs conflict when I open my game twice at once.
Hi,
When I play multiple copies of the same game file the playerprefs conflict which each other. I.e. if I play as 'Greg on one exe then play as 'Mike' on the other exe a moment later (while both games are still running), both games will now think Mike is logged in.
Does anyone know what might be causing this / solutions to prevent it?
Thanks!
unity stores the player prefs in a common place and it's not intended to have multiple instances of an app accessing them - you'll need to create unique names, perhaps by appending the player name...
Ahh yes i see. That should work, I will try it. Thanks :)
Answer by justaddice83 · Apr 08, 2015 at 01:24 PM
Use profilenames would work yes. A nicer solution would be to keep track of how many instances are running using a playerpref value which all instances can access. For example you could increment an 'int' on Start() and decremented on OnApplicationQuit(). Use that 'int' value as your unique ID for instance independent playerprefs.
That solution would perhaps be more elegant than letting the user select a different profile manually.