Created
December 6, 2015 10:46
-
-
Save peroon/de353c8699a00546414c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class SystemWrapper{ | |
// AndroidでSystemInfo.deviceUniqueIdentifierを使うとアクセス権限が増えるので回避 | |
public static string GetDeviceUniqueIdentifier(){ | |
#if UNITY_ANDROID || UNITY_EDITOR | |
string key = PlayerPrefsKey.userId; | |
if(PlayerPrefs.HasKey(key)){ | |
return PlayerPrefs.GetString(key); | |
}else{ | |
var userId = GenerateUserId(); | |
PlayerPrefs.SetString(key, userId); | |
return userId; | |
} | |
#else | |
return SystemInfo.deviceUniqueIdentifier; | |
#endif | |
} | |
public static string GenerateUserId(){ | |
Debug.Log ("新しいユーザIDを発行"); | |
return System.DateTime.Now.ToString () + Random.Range (1, 10000000).ToString (); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment