赞
踩
目录
创建脚本的时候添加脚本的介绍

- using System.IO;
-
- /// <summary>
- /// 创建脚本自动添加头注
- /// </summary>
- public class CommentFirst : UnityEditor.AssetModificationProcessor
- {
- /// <summary>
- /// 在资源创建生成.meta时调用
- /// </summary>
- /// <param name="path">自动传入资源路径</param>
- public static void OnWillCreateAsset(string path)
- {
- path = path.Replace(".meta", "");
- if (!path.EndsWith(".cs")) return;
- string allText = "// ========================================================\r\n"
- + "// 描述:\r\n"
- + "// 功能:\r\n"
- + "// 作者:XXX \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);
- }
- }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。