C#代码添加脚本头

目录

前言

代码展示


前言

创建脚本的时候添加脚本的介绍

代码展示

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);
    }
}

相关推荐

  1. C++ 脚本处理代码记录

    2024-02-04 18:52:03       16 阅读
  2. centos 7 添加启动脚本

    2024-02-04 18:52:03       16 阅读
  3. C 文件

    2024-02-04 18:52:03       13 阅读
  4. c/c++】编写文件

    2024-02-04 18:52:03       13 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-02-04 18:52:03       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-02-04 18:52:03       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-02-04 18:52:03       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-02-04 18:52:03       18 阅读

热门阅读

  1. 20240203周报—Tomcat暂时收尾,SpringBoot开始

    2024-02-04 18:52:03       35 阅读
  2. c# 语音播报

    2024-02-04 18:52:03       34 阅读
  3. BindingResult的作用

    2024-02-04 18:52:03       24 阅读
  4. bind: address already in use exit status 1端口占用

    2024-02-04 18:52:03       29 阅读
  5. Linux的7个运行级别

    2024-02-04 18:52:03       38 阅读
  6. LeetCode 0292.Nim 游戏:脑筋急转弯

    2024-02-04 18:52:03       33 阅读
  7. 倒计时65天

    2024-02-04 18:52:03       27 阅读
  8. [ubuntu]add-apt-repository 添加以及移除

    2024-02-04 18:52:03       29 阅读
  9. ubuntu22.04 VMware17.5

    2024-02-04 18:52:03       26 阅读
  10. Linux定时器

    2024-02-04 18:52:03       33 阅读
  11. Web中的Eval和Bind

    2024-02-04 18:52:03       30 阅读
  12. 【无标题】

    2024-02-04 18:52:03       27 阅读