I had the same question. This is how I resolved it. Note: this is basically a hack, I was using ILSpy to look at how unity does it, and it relies on a bunch of internal classes and functions.
What I opted up for, was getting the project window’s reference, selecting the asset I have just created, and sending a keyEvent to the window with F2 as the key. Granted this only works for windows but you can find out which key to send if you need it to work on Mac.
For information on getting the window’s reference, I would refer you to this thread:
http://answers.unity3d.com/questions/267097/editor-programming-experts-regarding-layouts.html
Note that the window name is different between unity 3 & 4 (there is more info on the above thread).
In code it looks like this:
private static System.Type ProjectWindowType = typeof(EditorWindow).Assembly.GetType("UnityEditor.ObjectBrowser");
private static EditorWindow projectWindow = null;
public static void StartRenameSelectedAsset()
{
if (projectWindow == null)
{
projectWindow = EditorWindow.GetWindow(ProjectWindowType);
}
//should never be null but still ;)
if (projectWindow != null)
{
var e = new Event();
e.keyCode = KeyCode.F2;
e.type = EventType.KeyDown;
projectWindow.SendEvent(e);
}
}
public static T CreateAssetAndStartRename<T>(string path = null, string assetName = null, string extension = ".asset") where T : ScriptableObject
{
var asset = CreateAsset<T>(path, assetName, extension, false);
Selection.activeObject = asset;
EditorUtility.FocusProjectWindow();
StartRenameSelectedAsset();
return asset;
}
So to use, you would call CreateAssetAndStartRename(), which in turn calls CreateAsset (this you should already have implemented from your question, so I didn’t include the code for that), sets the new asset as the active selection, focuses the project window, and then calls StartRenameSelectedAsset(), which makes sure there is a reference to the window, and sends it the event.
As you can tell these are static functions, I just have them in my CustomAssetUtility class. Using the generics here allows this to work with any scriptable object in the game (in my case, you can always extend the support obviously thorugh your own CreateAsset().