- Home /
Automatic unique value for inspector serialized field
I have string serialized field in my class and many other classes heritage from it, the point is I need that value to be filled in the inspector automatically for that instance, no matter where it comes from, if you just inserted the script component to the object, or if it's part or a prefab and you just inserted the prefab on the scene, or even cloned the prefab, in all those cases I need this value to be recalculated and unique amongst all other object instances. I've seen the Reset() method for MonoBehaviour, but that only get's called when putting the script component into an object for the first time (no effect when dragging the prefab containing it into the scene, or cloning with Ctrl+D), I've seen the [ExecuteInEditMode] aproach and validate the GetInstanceID() but that messes up my original object Awake, Start and Update and his heritages and I don't want to be putting an Application.isPlaying validation in every class. I've seen the custom drawer approach, but I don't really know how to deal with that, the only "custom property render" that I would want is the string I want to automatically fill and don't know how to automatically deal with all the rest of the serialized fields I don't really care how they are rendered, just want to have access to the inspector value and set it with a custom algorithm if it's empty or just got duplicated, thanks in advance :D.
Your answer
![](https://koobas.hobune.stream/wayback/20220613001124im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
CustomEditor : DrawDefaultInspector for Class 1 Answer
Inspector Titlebar for class derived from Object 1 Answer
How do I change inspector values of other game objects using a custom Editor Window 0 Answers
Inspector top not working properly 0 Answers
Inspector: custom property with custom type use default editor 3 Answers