Skip to content

Commit c16c6f7

Browse files
authored
Code description
1 parent 7a3d5b7 commit c16c6f7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Runtime/Model/MachineIdStorage.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@ internal string GenerateMachineId()
5858
private string FetchMachineIdFromStorage()
5959
{
6060
var storedMachineId = PlayerPrefs.GetString(MachineIdentifierKey);
61+
// in the previous version of the SDK, the stored machine id could be invalid
62+
// to fix the problem, we want to verify if the id is valid and if isn't, fix it.
6163
if (Guid.TryParse(storedMachineId, out Guid _))
6264
{
6365
return storedMachineId;
6466
}
65-
67+
6668
var machineId = ConvertStringToGuid(storedMachineId).ToString();
6769
StoreMachineId(machineId);
6870
return machineId;
@@ -124,9 +126,13 @@ protected virtual string UseNetworkingIdentifier()
124126

125127
return null;
126128
}
127-
129+
/// <summary>
130+
/// Converts a string with machine id into guid.
131+
/// </summary>
128132
private Guid ConvertStringToGuid(string value)
129133
{
134+
// to make sure we're supporting old version of Unity that can use .NET 3.5
135+
// we're using an older API to generate a GUID.
130136
MD5 md5 = new MD5CryptoServiceProvider();
131137
return new Guid(md5.ComputeHash(Encoding.UTF8.GetBytes(value)));
132138

0 commit comments

Comments
 (0)