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();
                }
            };
        }
    }
}
相关推荐
timathy331 天前
Unity Addressable 实现Build时自定义剔除资源组
unity·游戏引擎
一种时光2 天前
Unity 获取当前播放的动画,判断是否是某个动画
unity·游戏引擎
不绝1912 天前
Unity入门 :场景叠加/预制体资源包/脚本资源/生命周期函数/Inspector页面
unity·游戏引擎
在路上看风景2 天前
20. 资源和脚本的绑定关系
unity
yj爆裂鼓手3 天前
unity对象池
unity·c#
在路上看风景3 天前
3.7 SRP Batcher
unity
快乐觉主吖3 天前
Unity方便修改产品名和包名的小工具
unity·游戏引擎
JIes__3 天前
Unity(二)——MonoBehavior中的重要内容
unity·游戏引擎
4Forsee4 天前
【增强现实】快速上手 Vuforia Unity Android AR 应用开发
android·unity·ar
两水先木示4 天前
【Unity】对指定物体进行描边——模板测试法
unity·游戏引擎·shader·外描边