예제 #1
0
        internal static UnityEngine.Object CreateScriptAssetFromTemplate(string pathName, string resourceFile)
        {
            string text = File.ReadAllText(resourceFile);

            text = text.Replace("#NOTRIM#", "");
            string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(pathName);

            text = text.Replace("#NAME#", fileNameWithoutExtension);
            string text2 = fileNameWithoutExtension.Replace(" ", "");

            text = text.Replace("#SCRIPTNAME#", text2);
            if (char.IsUpper(text2, 0))
            {
                text2 = char.ToLower(text2[0]) + text2.Substring(1);
                text  = text.Replace("#SCRIPTNAME_LOWER#", text2);
            }
            else
            {
                text2 = "my" + char.ToUpper(text2[0]) + text2.Substring(1);
                text  = text.Replace("#SCRIPTNAME_LOWER#", text2);
            }
            return(ProjectWindowUtil.CreateScriptAssetWithContent(pathName, text));
        }