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();
                }
            };
        }
    }
}
相关推荐
在路上看风景12 小时前
15. 纹理尺寸是4的倍数
unity
AT~15 小时前
unity 使用Socket和protobuf实现网络连接
unity·游戏引擎
怣疯knight21 小时前
Cocos creator判断节点是否能用的方法
unity·cocos2d
tealcwu21 小时前
Google Play的Keystore不可用时的解决方法
unity
呼呼突突1 天前
Unity使用TouchSocket的RPC
unity·rpc·游戏引擎
qq 180809512 天前
从零构建一个多目标多传感器融合跟踪器
unity
平行云2 天前
实时云渲染支持在网页上运行UE5开发的3A大作Lyra项目
unity·云原生·ue5·webgl·虚拟现实·实时云渲染·像素流送
鹏飞于天2 天前
Shader compiler initialization error: Failed to read D3DCompiler DLL file
unity
wonder135792 天前
UGUI重建流程和优化
unity·游戏开发·ugui
那个村的李富贵2 天前
Unity打包Webgl后 本地运行测试
unity·webgl