- Home /
Editor prompt asset name
Hello,
When I do right click-> Create -> C# Script, A new c sharp file is created and I am prompted to give it a name.
Is there any way to do this with an Editor Script, so I can be prompted for a file name when I do the following:
right Click -> Ed's Custom Stuff -> Create Ed's custom Asset.
Thank you in advance.
Answer by HappyMoo · Jan 02, 2014 at 07:11 PM
There are some methods in EditorUtility...
http://docs.unity3d.com/Documentation/ScriptReference/EditorUtility.html
I do understand I could create my own text field or window or bring up "Save As" but what I was trying to replicate the na$$anonymous$$g behaviour for when one creates a material or script.
Answer by SorraTheOrc · Jan 25, 2018 at 06:11 AM
[MenuItem("Assets/Create/WorldSim/New Metric")]
public static void Create()
{
string assetPath = "Assets/Data/Resource/New Resource.asset";
Metric asset = ScriptableObject.CreateInstance<Metric>();
ProjectWindowUtil.CreateAsset(asset, assetPath);
}
Inspired by https://answers.unity.com/questions/480226/select-asset-for-rename.html
Your answer
![](https://koobas.hobune.stream/wayback/20220613125358im_/https://answers.unity.com/themes/thub/images/avi.jpg)