I need to create an ScriptableObject asset with custom name (like when I create material, I can type the name).
However, this code allows me to only create assets with fixed name:
public static void CreateAsset<T>() where T : ScriptableObject
{
T asset = ScriptableObject.CreateInstance<T>();
string path = AssetDatabase.GetAssetPath(Selection.activeObject);
if (path == "")
{
path = "Assets";
}
else if (Path.GetExtension(path) != "")
{
path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), "");
}
string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + "/New " + typeof(T).ToString() + ".asset");
AssetDatabase.
AssetDatabase.CreateAsset(asset, assetPathAndName);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
EditorUtility.FocusProjectWindow();
Selection.activeObject = asset;
}
}
How could I make this name the name I write like when creating materials, scripts, folders etc?
[edit] I can change the name simply by clicking it, but if someone knows clean solution which allows me to make it behave like build in objects, it would still be apperciated.
Use rigidbody.velocity in local space. I think it might help you http://answers.unity3d.com/questions/193398/velocity-relative-to-local.html
– Welgum