internal static Object CreateScriptAssetFromTemplate(string pathName, string resourceFile)
{
string fullPath = Path.GetFullPath(pathName);
string contents = File.ReadAllText(resourceFile).Replace("#NOTRIM#", "");
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(pathName);
contents = contents.Replace("#NAME#", fileNameWithoutExtension);
string newValue = fileNameWithoutExtension.Replace(" ", "");
contents = contents.Replace("#SCRIPTNAME#", newValue);
if (char.IsUpper(newValue, 0))
{
newValue = char.ToLower(newValue[0]) + newValue.Substring(1);
contents = contents.Replace("#SCRIPTNAME_LOWER#", newValue);
}
else
{
newValue = "my" + char.ToUpper(newValue[0]) + newValue.Substring(1);
contents = contents.Replace("#SCRIPTNAME_LOWER#", newValue);
}
UTF8Encoding encoding = new UTF8Encoding(true);
File.WriteAllText(fullPath, contents, encoding);
AssetDatabase.ImportAsset(pathName);
return AssetDatabase.LoadAssetAtPath(pathName, typeof(Object));
}