Skip to content

Instantly share code, notes, and snippets.

@SiarheiPilat
Forked from johnsoncodehk/CreateScriptAsset.cs
Created January 13, 2022 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SiarheiPilat/294097209114ef0279e2b1048e8f7c9f to your computer and use it in GitHub Desktop.
Save SiarheiPilat/294097209114ef0279e2b1048e8f7c9f to your computer and use it in GitHub Desktop.
Create script from template in project
// Not support of 2019.1.0f1
static void CreateScriptAsset(string templatePath, string destName) {
#if UNITY_2019_1_OR_NEWER
UnityEditor.ProjectWindowUtil.CreateScriptAssetFromTemplateFile(templatePath, destName);
#else
typeof(UnityEditor.ProjectWindowUtil)
.GetMethod("CreateScriptAsset", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)
.Invoke(null, new object[] { templatePath, destName });
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment