第一種方式 :
直接找到unity 安裝路徑一層層的找
D:\Unity\2019.2.17f1\Editor\Data\Resources\ScriptTemplates 打開 81-C# Script-NewBehaviourScript.cs文件
打開文件添加自己想要添加的描述
#region
// **********************************************************************
// 描述:這是一個功能代碼\r\n"
// 創建時間:#CreateTime#\r\n"
// 作者:懶羊羊 \r\n"
// 版 本:1.0\r\n"
// **********************************************************************
#endregion
第二種方式:
在unity 中創建一個Editor 文件夾代碼如下
using UnityEditor;
using System.IO;
public class AutoSetScriptHead : UnityEditor.AssetModificationProcessor
{
//導入資源創建資源時候調用
public static void OnWillCreateAsset(string path)
{
path = path.Replace(".meta", "");
if (!path.EndsWith(".cs"))
{
return;
}
string showMes = "//" +
"***********************************************************\r\n"
+ "// 描述:這是一個功能代碼\r\n"
+ "// 作者:懶羊羊 \r\n"
+ "// 創建時間:#CreateTime#\r\n"
+ "// 版 本:1.0\r\n"
+ "//"
+ "***********************************************************\r\n";
showMes += File.ReadAllText(path);
showMes = showMes.Replace("#CreateTime#", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
File.WriteAllText(path, showMes);
}
}