Python_修正Unity离线手册打开缓慢的问题

unity的离线手册是静态的html,因为某些原因打开的时候会很慢很慢

最直接的解决方法是断网,当然了,断网使用体验太差了,

也可以通过改环境的方法解决,例如小飞机或者改host等等,

如果不想改环境,可以把所有html文件里的关键文本改掉,

下面代码通过Python代码删掉html中的:

cdn.cookielaw.org/scripttemplates/otSDKStub.js

www.googletagmanager.com

fonts.googleapis.com

代码

#!/usr/bin/env python3

import os

fileNum = 0
for (dirpath, dirs, files) in os.walk(os.path.curdir):
    for file in files:
        if file.endswith(".html"):
            filePath = os.path.join(dirpath,file)
            with open(filePath,'r',encoding='utf-8') as f:
                s = f.read().replace("cdn.cookielaw.org/scripttemplates/otSDKStub.js",'').replace("www.googletagmanager.com",'').replace("fonts.googleapis.com",'')
            with open(filePath,'w',encoding='utf-8') as f:
                f.write(s)

            fileNum = fileNum + 1
            message = ">>>修改完成  进度:" + f'{round(fileNum / 25414 * 100, 2)}' + "%  文件: " + filePath
            print(message)

print("共修改",fileNum,"个文件")


注意

注意在文档路径里运行

手册下载

Uinty离线手册(2020.3)的官方下载链接:

英文版:https://storage.googleapis.com/docscloudstorage/2020.3/UnityDocumentation.zip

中文版:https://storage.googleapis.com/localized_docs/zh-cn/2020.3/UnityDocumentation.zip

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值