There's a script called ES2UniqueID that is used in an example to generate unique IDs in order to create an automatic saving system.
I'm running into issues with the GenerateUniqueID() generating duplicate IDs because I'm destroying and then creating again objects.
Code: Select all
private static int GenerateUniqueID()
{
// If no unique IDs have yet been set, use zero.
if(uniqueIDList.Count == 0)
return 0;
// Get the last (and thus highest) number in the list
// and then add 1 to it to get a new unique number.
return uniqueIDList[uniqueIDList.Count-1].id+1;
}
Code: Select all
System.Guid.NewGuid().ToString()