Page 1 of 1
Saver keys
Posted: Mon Dec 05, 2022 6:46 am
by SealDev
If I have multiple levels with objects with the same name and I use the "Assign Unique Keys" tool, is there a very low chance 2 savers will get assigned the same identifier key number? (Example: "SAVER_931386"), or does the system know how to check if a key has already been used in the whole entire project?
Might be a very small chance for now, but if I duplicated 1000 scenes that contain that "SAVER" gameobject, the chance of overriding a past key would become much larger.
Re: Saver keys
Posted: Mon Dec 05, 2022 9:01 am
by Tony Li
Hi,
Yes, there's a very, very low chance of duplicates -- not as low as using GUIDs, but still very low, and these key values are shorter than GUIDs. You can assign keys manually if you're concerned.
Re: Saver keys
Posted: Sat Dec 10, 2022 9:38 am
by SealDev
Right now, chance is 1 in a Million because the saver keys generate with 6 digits.
Is there a script where I could easily add 1-2 more digits to the "Assign unique keys" tool, so that the chance becomes 1 in 100 Million?
Re: Saver keys
Posted: Sat Dec 10, 2022 10:41 am
by Tony Li
You could assign keys manually or tick the savers' Append Saver Type checkbox. Or you could duplicate SaveSystemEditorUtility.cs, change the class name, and modify the AssignNewKey method to use something like System.Guid.NewGuid() instead of saver.GetInstanceID() to generate the key.