I was faced with the fact that LoginWithCustomID does not work under WebGL (all connected users are authorized on one account).
And also with the fact that the client running in the editor has the same deviceId as the build client (it's a trifle, but still not convenient, since network games usually debug in conjunction with several running clients).
To fix this situation, I made the following changes to the DeviceUniqueIdentifier function.
public static string DeviceUniqueIdentifier { get { var deviceId = ""; #if UNITY_EDITOR deviceId = SystemInfo.deviceUniqueIdentifier + "-editor"; #elif UNITY_ANDROID AndroidJavaClass up = new AndroidJavaClass ("com.unity3d.player.UnityPlayer"); AndroidJavaObject currentActivity = up.GetStatic<AndroidJavaObject> ("currentActivity"); AndroidJavaObject contentResolver = currentActivity.Call<AndroidJavaObject> ("getContentResolver"); AndroidJavaClass secure = new AndroidJavaClass ("android.provider.Settings$Secure"); deviceId = secure.CallStatic<string> ("getString", contentResolver, "android_id"); #elif UNITY_WEBGL if (!PlayerPrefs.HasKey("UniqueIdentifier")) PlayerPrefs.SetString("UniqueIdentifier", Guid.NewGuid().ToString()); deviceId = PlayerPrefs.GetString("UniqueIdentifier"); #else deviceId = SystemInfo.deviceUniqueIdentifier; #endif return deviceId; } }
Is this a correct practice? Or is there a more competent solution?