Skip to content

Instantly share code, notes, and snippets.

@peroon
Created December 6, 2015 10:46
Show Gist options
  • Save peroon/de353c8699a00546414c to your computer and use it in GitHub Desktop.
Save peroon/de353c8699a00546414c to your computer and use it in GitHub Desktop.
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