普通脚本模板,带命名空间
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MyFarm
{
public class #SCRIPTNAME#
{
DO NOT COMPILE!
}
}

编辑器代码
cs
[MenuItem("Assets/Create/脚本带命名空间", false, 80)]
public static void CreateScriptWithNamespace()
{
string path = Application.dataPath+
@"/ScriptTemplates\ScriptTemplate.txt";
ProjectWindowUtil.CreateScriptAssetFromTemplateFile(path, "哈哈哈.cs");
}
编辑器窗口模板
cs
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace MyFarm
{
public class #SCRIPTNAME# : EditorWindow
{
[MenuItem("我的工具/#SCRIPTNAME#窗口")]
static void OpenWindow()
{
GetWindow<#SCRIPTNAME#>(false, "工具", true);
}
void OnGUI()
{
哈!
}
}
}
代码
cs
[MenuItem("Assets/Create/编辑器窗口脚本", false, 80)]
public static void CreateWindowScript()
{
string path = Application.dataPath +
@"/ScriptTemplates\WindowTemp.txt";
ProjectWindowUtil.CreateScriptAssetFromTemplateFile
(path, "哈哈哈.cs");
}