- Home /
Which Scriptableobject's Callback should I use to be updated when the name of a asset file of a SO change?
I have a custom property called Name on a scriptableobject. I want Name to always equal to Object.name, which is the name of the asset file of the scriptableobject (I think). It will be updated when I first create the scriptableobject with [CreateAssetMenu] or when I change the file's name. What is the most suitable Callback to do this? (Awake, OnEnable, OnValidate, etc)
Answer by logicandchaos · Mar 01, 2021 at 03:18 PM
OnValidate, but I'm not sure if changing the files name will trigger it. Could you not just use Object.name instead of making a property for it? Or since it's a property already you could make the get method like this: public void GetName(){ return Object.Name;}
I can't just use the Object.name because there is some Scriptable object that is an asset file (with proper Object.name) and others that are created in memory. Also, I want to change it in the inspector (hence the Name property) so I decided to just use Name for all, which means I have to update it with the Object.name when necessary.
Your answer
![](https://koobas.hobune.stream/wayback/20220613030009im_/https://answers.unity.com/themes/thub/images/avi.jpg)