SystemInfo.deviceUniqueIdentifierはUnityやOSのバージョンが変わると変わってしまうので一意のIDとしては使わない方がよいです。一番簡単で確実なのはID用のデータベースを設けて照合するといいと思います。
UNITY コードは未検証です
C#
1public static IEnumerator getMyID(string url)
2{
3 using (UnityWebRequest request = new UnityWebRequest(url))
4 {
5 request.method = UnityWebRequest.kHttpVerbGET;
6 request.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
7
8 yield return request.Send();
9
10 if((int)request.responseCode < 299
11 && (int)request.responseCode == 200
12 && !string.IsNullOrEmpty(request.downloadHandler.text))
13 {
14 var myID = request.downloadHandler.text;
15 //ここでIDを保存
16 }
17 }
18}
PHP
PHP
1<?php
2
3try
4{
5 //(データベースの接続など省略)
6 //ユーザーIDを設定
7 while (true)
8 {
9 $userID = "id_" . randomID();
10 $query = "select * from user_info where id=?";
11
12 //selectは自作クラスのメソッドです。PDOを使い$queryをprepare、$userIDをexecuteして返ったデータが$resultに入るイメージです。存在しなければ0の配列が返るようにしています。
13 $result = $dbFn->select($query, [ $userID ]);
14
15 if(count($result) == 0) break;
16 }
17
18}catch (Exception $e)
19{
20
21}
22
23//ランダムなIDを生成
24function randomID($length = 10)
25{
26 return substr(str_shuffle('1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, $length);
27}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。