【问题标题】:Qt WebEngineView: Problem with loading a WebGL project (exported from Unity)Qt WebEngineView:加载 WebGL 项目时出现问题(从 Unity 导出)
【发布时间】:2019-10-17 10:14:49
【问题描述】:

我正在尝试在 Qt WebEngineView (Qt 5.12.0) 中下载一个 WebGL 项目(从 Unity 2018.3.14f1 导出)

例如,WebGL 项目是在 Unity 2018 中创建的 - 一个没有对象的空场景(仅限相机) - 屏幕截图:Unity 项目

并导出到 WebGL 程序集(应用 .gzip 压缩,构建大小 2.3 MB) - 屏幕截图:Unity 构建设置

Qt 项目取自 Qt 的示例库(“WebEngine Widgets Minimal Example”)。

#include <QApplication>
#include <QWebEngineView>

QUrl commandLineUrlArgument()
{
    const QStringList args = QCoreApplication::arguments();
    for (const QString &arg : args.mid(1)) {
        if (!arg.startsWith(QLatin1Char('-')))
            return QUrl::fromUserInput(arg);
    }
    return QUrl(QStringLiteral("file:///F:/qt/test4Exp/index.html"));
}

int main(int argc, char *argv[])
{
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QApplication app(argc, argv);

    QWebEngineView view;
    view.setUrl(commandLineUrlArgument());
    view.resize(1024, 750);
    view.show();

    return app.exec();
}

当您在 Chrome 中打开 WebGL 项目时,一切都加载得非常快(瞬间) - 屏幕截图:在 Chrome 中打开的 WebGL 项目

当您在 WebEngineView 中打开 WebGL 时,项目需要很长时间才能加载(大约 5-6 分钟) - 屏幕截图:WebEngineView 中的 WebGL 项目加载

...但随后它会打开 - 屏幕截图:在 WebEngineView 中加载的 WebGL 项目

WebGL 项目是从本地驱动器打开的。我尝试了 Unity 导出参数的各种选项(brodil 压缩、代码优化等)。告诉我,可能是什么问题?可以应用于 Assembly 或 QCoreApplication::setAttribute 中的任何选项?

下面附上项目WebGL和Qt项目

WebGL Project

Qt Project

【问题讨论】:

    标签: c++ qt unity3d unity-webgl webengine


    【解决方案1】:

    从 exe 文件下(不是从 QtCreator 下)运行应用程序后问题得到解决。在 exe 文件下一切运行得更快。显然,QtCreator 减慢了 Unity 引擎的启动和初始化。当应用程序在 exe 下运行时,在 Web Engine View 中启动 web 项目需要 2-3 秒(在旧 PC 上需要 7-9 秒)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-27
      • 1970-01-01
      • 1970-01-01
      • 2016-06-21
      • 1970-01-01
      • 2011-07-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多