unity editor 修改注释模板

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using System;
using UnityEditor;


public class ScriptCreatInit : UnityEditor.AssetModificationProcessor {


    private static string strContent = "//============================================\r\n"
        + "// 描述: \r\n"
        + "//作者:AuthoRName\r\n"
        + "//创建时间:CreateTime\r\n"
         + "//版本:v1.0\r\n"
        + "//==============================================\r\n";




    private static void OnWillCreateAsset(string path)
    { 
        path = path.Replace(".meta", "");
        if (path.EndsWith(".cs"))
        {
           strContent += File.ReadAllText(path);
            strContent = strContent.Replace("AuthoRName", "RainSnow").Replace("CreateTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            File.WriteAllText(path, strContent);
            AssetDatabase.Refresh();
        }
    }

}








将此脚本放在Editor文件夹下即可

猜你喜欢

转载自blog.csdn.net/gao7009/article/details/80566876
今日推荐