Below is my code. The last if statement doesn’t seem to function correctly for me and I cant work out why. If I run it commented out as below, I can duplicate an enemy in scene and get a GUID generated and it will stay between scenes. If I uncomment and run the full IsUnique, each enemy then duplicated shares the same GUID. Can any one see what is wrong.
private bool IsUnique(string candidate) {
//checks key exists in dictionary
if (!globalLookup.ContainsKey(candidate)) {
return true;
}
//checks not pointing to ourselves
if (globalLookup[candidate] == this) {
return true;
}
//if deleted then remove from dictionary
if (globalLookup[candidate] == null) {
globalLookup.Remove(candidate);
return true;
}
//if (globalLookup[candidate].GetUniqueIdetifier() != candidate) {
//
// globalLookup.Remove(candidate);
// return true;
//}
return false;
}
cheers