unity自动添加头部注释脚本

unity自动添加头部注释脚本,放在Assets目录自动生效

csharp 复制代码
public class ScriptCreateInit : UnityEditor.AssetModificationProcessor
{
    private static void OnWillCreateAsset(string path)
    {
        path = path.Replace(".meta", "");
        if (path.EndsWith(".cs"))
        {
            EditorApplication.delayCall += () =>
            {
                string scriptContent = "//==============================\n";
                scriptContent += "//Author: yiaomumu \n";
                scriptContent += "//Email: yiaomumu@qq.com\n";
                scriptContent += "//Created on: " + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\n";
                scriptContent += "//==============================\n\n";
                if (!File.ReadAllText(path).Contains("//Author"))
                {
                    scriptContent += File.ReadAllText(path);
                    File.WriteAllText(path, scriptContent);
                    AssetDatabase.Refresh();
                }
            };
        }
    }
}
相关推荐
RReality9 小时前
【Unity Shader URP】序列帧动画(Sprite Sheet)实战教程
unity·游戏引擎
mxwin9 小时前
Unity URP 多线程渲染:理解 Shader 变体对加载时间的影响
unity·游戏引擎·shader
呆呆敲代码的小Y10 小时前
【Unity工具篇】| 游戏完整资源热更新流程,YooAsset官方示例项目
人工智能·游戏·unity·游戏引擎·热更新·yooasset·免费游戏
黄思搏2 天前
基于标注平台数据的 Unity UI 自动化构建工作流设计与工程实践
ui·unity·蓝湖·vectoui
羊羊20352 天前
开发手札:Unity6000与Android交互
android·unity·android-studio
Sator13 天前
Unity AStarPath的踩坑点
unity
星河耀银海3 天前
Unity基础:摄像机Camera的参数设置与视角控制
unity·游戏引擎·lucene
星河耀银海3 天前
Unity基础:Transform组件的位移、旋转与缩放详解
unity·游戏引擎·lucene
海清河晏1114 天前
数据结构 | 单链表
数据结构·unity·dreamweaver
mxwin4 天前
Unity URP 下 MatCap 技术详解 无视光照环境的卡通与质感渲染方案
unity·游戏引擎