Skip to content

Instantly share code, notes, and snippets.

@johnsoncodehk
Last active January 18, 2024 10:00

Revisions

  1. johnsoncodehk revised this gist Jan 16, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion CreateScriptAsset.cs
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    static void CreateScriptAsset(string templatePath, string destName) {
    #if UNITY_2019_1_OR_NEWER
    ProjectWindowUtil.CreateScriptAssetFromTemplateFile(templatePath, destName);
    UnityEditor.ProjectWindowUtil.CreateScriptAssetFromTemplateFile(templatePath, destName);
    #else
    typeof(UnityEditor.ProjectWindowUtil)
    .GetMethod("CreateScriptAsset", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)
  2. johnsoncodehk revised this gist Jan 16, 2020. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions CreateScriptAsset.cs
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,11 @@
    // Not support of 2019.1.0f1

    static void CreateScriptAsset(string templatePath, string destName) {
    #if UNITY_2019_1_OR_NEWER
    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
    }
  3. johnsoncodehk revised this gist Jun 15, 2018. No changes.
  4. johnsoncodehk created this gist Jun 15, 2018.
    5 changes: 5 additions & 0 deletions CreateScriptAsset.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    static void CreateScriptAsset(string templatePath, string destName) {
    typeof(UnityEditor.ProjectWindowUtil)
    .GetMethod("CreateScriptAsset", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)
    .Invoke(null, new object[] { templatePath, destName });
    }