この回答はGPT-4による自動生成回答です
ハッシュIDの取得方法は、以下の手順で行うことができます。
- まず、以下のスクリプトをUnityプロジェクトに追加してください。
csharp
1using System;
2using UnityEngine;
3using UnityEngine.Android;
4
5public class DeviceIdManager : MonoBehaviour
6{
7 void Start()
8 {
9 if (Permission.HasUserAuthorizedPermission(Permission.ExternalStorageRead))
10 {
11 GetDeviceId();
12 }
13 else
14 {
15 Permission.RequestUserPermission(Permission.ExternalStorageRead);
16 GetDeviceId();
17 }
18 }
19
20 void GetDeviceId()
21 {
22 string deviceId = SystemInfo.deviceUniqueIdentifier;
23 string hashedDeviceId = Md5Sum(deviceId).ToUpper();
24 Debug.Log("Device ID: " + deviceId);
25 Debug.Log("Hashed Device ID: " + hashedDeviceId);
26 }
27
28 public static string Md5Sum(string strToEncrypt)
29 {
30 System.Text.UTF8Encoding ue = new System.Text.UTF8Encoding();
31 byte[] bytes = ue.GetBytes(strToEncrypt);
32
33 // encrypt bytes
34 System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
35 byte[] hashBytes = md5.ComputeHash(bytes);
36
37 // Convert the encrypted bytes back to a string (base 16)
38 string hashString = "";
39
40 for (int i = 0; i < hashBytes.Length; i++)
41 {
42 hashString += System.Convert.ToString(hashBytes[i], 16).PadLeft(2, '0');
43 }
44
45 return hashString.PadLeft(32, '0');
46 }
47}
-
このスクリプトを任意のGameObjectにアタッチして、シーンを実行します。
-
Unityのコンソールに表示されるHashed Device ID
をコピーして、AdMobのテストデバイスとして登録します。
これで、ハッシュIDを取得し、AdMobのテストデバイスに登録することができます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2023/06/27 22:36