刷新会复制代码,暂时弃用
This commit is contained in:
@@ -1,40 +1,40 @@
|
|||||||
using System;
|
// using System;
|
||||||
using System.IO;
|
// using System.IO;
|
||||||
|
//
|
||||||
namespace Stary.Evo.Editor
|
// namespace Stary.Evo.Editor
|
||||||
{
|
// {
|
||||||
public class ChangeScriptTemplates : UnityEditor.AssetModificationProcessor
|
// public class ChangeScriptTemplates : UnityEditor.AssetModificationProcessor
|
||||||
{
|
// {
|
||||||
// 要添加的注释的内容
|
// // 要添加的注释的内容
|
||||||
private static string annotationStr =
|
// private static string annotationStr =
|
||||||
"/**************************************************** \r\n"
|
// "/**************************************************** \r\n"
|
||||||
+ " 文件:#Filename\r\n"
|
// + " 文件:#Filename\r\n"
|
||||||
+ " 作者:#CreateAuthor#\r\n"
|
// + " 作者:#CreateAuthor#\r\n"
|
||||||
+ " 邮箱:\r\n"
|
// + " 邮箱:\r\n"
|
||||||
+ " 日期:#CreateTime#\r\n"
|
// + " 日期:#CreateTime#\r\n"
|
||||||
+ " 功能:\r\n"
|
// + " 功能:\r\n"
|
||||||
+ "*****************************************************/\r\n\n";
|
// + "*****************************************************/\r\n\n";
|
||||||
|
//
|
||||||
public static void OnWillCreateAsset(string path)
|
// public static void OnWillCreateAsset(string path)
|
||||||
{
|
// {
|
||||||
//将.meta后缀屏蔽
|
// //将.meta后缀屏蔽
|
||||||
path = path.Replace(".meta", "");
|
// path = path.Replace(".meta", "");
|
||||||
//只对.cs脚本作操作
|
// //只对.cs脚本作操作
|
||||||
if (path.EndsWith(".cs"))
|
// if (path.EndsWith(".cs"))
|
||||||
{
|
// {
|
||||||
//读取该路径下的.cs文件中的所有文本.
|
// //读取该路径下的.cs文件中的所有文本.
|
||||||
//注意,此时Unity已经对脚本完成了模版内容的替换,包括#SCRIPTNAME#也已经被替换为文件名了,读取到的是替换后的文本内容.
|
// //注意,此时Unity已经对脚本完成了模版内容的替换,包括#SCRIPTNAME#也已经被替换为文件名了,读取到的是替换后的文本内容.
|
||||||
annotationStr += File.ReadAllText(path);
|
// annotationStr += File.ReadAllText(path);
|
||||||
//获取用户名和当前系统时间并替换对应位置内容
|
// //获取用户名和当前系统时间并替换对应位置内容
|
||||||
annotationStr = annotationStr.Replace("#CreateAuthor#", Environment.UserName)
|
// annotationStr = annotationStr.Replace("#CreateAuthor#", Environment.UserName)
|
||||||
.Replace("#CreateTime#", string.Concat(DateTime.Now.Year, "/", DateTime.Now.Month, "/",
|
// .Replace("#CreateTime#", string.Concat(DateTime.Now.Year, "/", DateTime.Now.Month, "/",
|
||||||
DateTime.Now.Day, " ", DateTime.Now.Hour, ":", DateTime.Now.Minute, ":", DateTime.Now.Second))
|
// DateTime.Now.Day, " ", DateTime.Now.Hour, ":", DateTime.Now.Minute, ":", DateTime.Now.Second))
|
||||||
.Replace("#Filename", Path.GetFileName(path));
|
// .Replace("#Filename", Path.GetFileName(path));
|
||||||
if (!File.ReadAllText(path).Contains("文件") && !File.ReadAllText(path).Contains("作者") && !File.ReadAllText(path).Contains("邮箱") && !File.ReadAllText(path).Contains("日期") && !File.ReadAllText(path).Contains("功能"))
|
// if (!File.ReadAllText(path).Contains("文件") && !File.ReadAllText(path).Contains("作者") && !File.ReadAllText(path).Contains("邮箱") && !File.ReadAllText(path).Contains("日期") && !File.ReadAllText(path).Contains("功能"))
|
||||||
//重新将文本写入.cs文件
|
// //重新将文本写入.cs文件
|
||||||
File.WriteAllText(path, annotationStr);
|
// File.WriteAllText(path, annotationStr);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
Reference in New Issue
Block a user