- Home /
Question by
dawitabraham · May 18, 2020 at 01:49 PM ·
unityeditorinspectorvariables
Unity how to validate/preprocess variables when they're assigned in the inspector
I have a string[] animationPaths variable. And I am using the OdinInspector library to drag and drop files into the inspector to get their paths. I want to preprocess the paths in order to remove the final ".prefab" extensions.
[OnValueChanged("UpdateAnimationPaths")]
[FilePath(ParentFolder = "Assets/Project/Resources")]
[SerializeField] private string[] animationPaths;
The OnValueChanged callback allows me to process the variables when one is changed. But the callback is not called when a variable is first assigned in the inspector.
Is there any way to preprocess variables the moment they are assigned in the inspector? (Without using the Update function)
Comment