public static void CreateShader()
{
string path = AssetDatabase.GetAssetPath(Selection.activeObject);
if (String.IsNullOrEmpty(path))
{
path = "Assets";
}
else if (!String.IsNullOrEmpty(Path.GetExtension(path)))
{
path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), "");
}
string filename = Path.Combine(path, "NewShaderProgram.shader");
string template = "Assets/Babylon/Templates/Shaders/amiga.template";
if (!File.Exists(template))
{
string defaultTemplate = "// Babylon Shader Class";
File.WriteAllText(template, defaultTemplate);
}
var icon = EditorGUIUtility.FindTexture("ScriptableObject Icon") as Texture2D;
var DoCreateScriptAsset = Type.GetType("UnityEditor.ProjectWindowCallback.DoCreateScriptAsset, UnityEditor");
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance(DoCreateScriptAsset) as UnityEditor.ProjectWindowCallback.EndNameEditAction, filename, icon, template);
}