1. 将对应 unity 版本目录 (.\Editor\Data\Resources\ScriptTemplates) 下的 81-C# Script-NewBehaviourScript.cs.txt 脚本模板文件中增加文件头信息
/****************************************************
文件:#SCRIPTNAME#.cs
作者:#CreateAuthor#
日期:#CreateTime#
性能:
*****************************************************/
using UnityEngine;
public class #SCRIPTNAME# : MonoBehaviour
{}
2. 在 Unity 工程文件夹 (Plugins\Editor) 创立增加提示信息的脚本
using System;
using System.IO;
public class HeadDetailedRecoder : UnityEditor.AssetModificationProcessor {private static void OnWillCreateAsset(string path) {path = path.Replace(".meta", "");
if (path.EndsWith(".cs")) {string str = File.ReadAllText(path);
str = str.Replace("#CreateAuthor#", "Pangdudu").Replace(
"#CreateTime#", string.Concat(DateTime.Now.Year, "/", DateTime.Now.Month, "/",
DateTime.Now.Day, "", DateTime.Now.Hour,":", DateTime.Now.Minute,":", DateTime.Now.Second));
File.WriteAllText(path, str);
}
}
}
这样就能够在 unity 中创立脚本时生成头文件。(也能够通过 Visual Assist X 增加脚本头文件信息)