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.

2 Answers

2

There are some methods in EditorUtility…

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 naming behaviour for when one creates a material or script.

–

Oh,I see... http://answers.unity3d.com/questions/480226/select-asset-for-rename.html

–

[MenuItem(“Assets/Create/WorldSim/New Metric”)]
public static void Create()
{
string assetPath = “Assets/Data/Resource/New Resource.asset”;
Metric asset = ScriptableObject.CreateInstance();
ProjectWindowUtil.CreateAsset(asset, assetPath);
}

Inspired by Select asset for rename - Unity Answers