Unity中创建代码时增加注释

using UnityEngine;
using System.Collections;
using System.IO;

public class Code : UnityEditor.AssetModificationProcessor {

    private static string annotationStr =
  "//====================================\r\n"
  + "//描 述 : \r\n"
  + "//作 者 :  \r\n"
  + "//创建时间 :#Time#  \r\n"
  + "//版 本 :  \r\n"
  + "// ===============================================\r\n";

    private static void OnWillCreateAsset(string path){
        path = path.Replace(".meta", "");
        if (path.EndsWith(".cs")){
            annotationStr += File.ReadAllText(path);
            annotationStr = annotationStr.Replace("#Time#",
                System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));

            File.WriteAllText(path, annotationStr);
        }
        Debug.Log(path);
    }

}

你可能感兴趣的:(Unity中创建代码时增加注释)