I have a bunch of gameObjects that I am assigning unique ids to in the Start function.
void Start() {
UniqueID = String.Format("{0:X}", DateTime.Now.Ticks);
}
I thought this would work but every now and then I get duplicate ids. How can I make sure that they are always unique?
I would use a guid.
UniqueID = Guid.NewGuid.ToString();
Using your suggestion, 2 instances running at same time, may apply the same "unique" UniqueID to 2 different objects.
Guid should be unique even across instances.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With