转载:https://itmonon.blog.csdn.net/article/details/117330558
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
public class FirstComment : UnityEditor.AssetModificationProcessor
{
public static void OnWillCreateAsset(string path)
{
path = path.Replace(".meta", "");
if (!path.EndsWith(".cs")) return;
string allText = "//===========================\r\n"
+ "//功能:\r\n"
+ "//作者:\r\n"
+ "//创建时间:#CreateTime#\r\n"
+ "//版本:1.0\r\n"
+ "//变更时间:\r\n"
+ "//变更版本:#CreateTime2\r\n"
+ "//脚本路径:#ScripsPath#\r\n"
+ "//===========================\r\n";
allText += File.ReadAllText(path);
allText = allText.Replace("#CreateTime#", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
allText = allText.Replace("#ScripsPath#", path);
File.WriteAllText(path, allText);
}
}