I want to create an asset file and let the user rename it.
First: I know about the CreateAssetMenu
attribute and do NOT want to use it for two reasons:
- I want to initialize the file to have some required values. But Unity does not like having a constructor and functions like Awake() and OnEnable() get called multiple times
- The user should be able to create a file by clicking a button in the inspector. After that, he/she renames the file.
So I created a function using [MenuItem("Assets/Create/My File")]
to create a file. This works totally fine but for using AssetDatabase.CreateAsset(file, path)
I need to specify a file name already.
So is there any way to instantly start the file name editing after creating the file just like it is done when just using CreateAssetMenu
?
Thanks
(Not sure if this is the right topic. Its the only one mentioning the Unity Editor)