Import progress doesn't count downloaded bytes

未关闭
#845 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
csharp, unity
领域
game-dev

调研方向

从 GLTFSceneImporter.LoadSceneAsync 以及 ImportProgress 和 UnityWebRequestLoader 入口开始,然后跟踪 Web 下载在 buffer、node 和 texture 导入开始之前如何报告进度。完成标准是:在 Web 模型下载期间,ImportProgress 能反映已下载的字节数,使加载条在整个操作过程中持续前进;该 issue 未指定任何文件或测试。

由索引模型根据 Issue 内容生成。

描述

Describe the bug 💬

The implementation ImportProgress.Progress doesn't take into consideration the download bytes when importing models from the web.

This means that when importing a web model, the Progress value stays at 0 during all the download phase (which is generally the longest one), then it rapidly goes to 1 when importing buffers, nodes and textures.

In this way it is impossible to create a loading bar. The only alternative I found is to download the file separately and then import it as usual.

Steps to reproduce 🔢

Import a .glb from web url with LoadSceneAsync() like this

private CancellationTokenSource tokenSource;
string directory = Path.GetDirectoryName(someWebUrl);
string fileName  = Path.GetFileName(someWebUrl);

...

ImportOptions importOpt = new ImportOptions
{
    DataLoader   = new UnityWebRequestLoader(directory),
    CameraImport = CameraImportOption.None
};

GLTFSceneImporter importer = new GLTFSceneImporter(fileName, importOpt);
Progress<ImportProgress> progressReporter = new Progress<ImportProgress>();
progressReporter.ProgressChanged += OnImportProgress;
importCancellationTokenSource = new CancellationTokenSource();
await importer.LoadSceneAsync(-1, true, OnImportComplete, tokenSource.Token, progressReporter);

...

private void OnImportProgress(object sender, ImportProgress prog)
{
    Debug.Log(Time.realTimeSinceStartup + " - " prog.ToString());
}

Notice how the logs show almost no progress while downloading, and then abruptly increase when the GLB import phase begins.

Files to reproduce the issue ♻

No response

Editor Version 🎲

6000.0.37

Render Pipeline and version

Any

Operating System 👩‍💻

Windows

When does this problem happen?
  • Editor Import
  • Runtime Import
  • Editor Export
  • Runtime Export
Additional Info 📜

No response

Validations 🩹
主要语言
C#
星标
2.3k
派生
539
平均合并
3 天 15 小时
30 天内合并 PR
2

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

KhronosGroup/UnityGLTF 的其他 Issue

查看 KhronosGroup/UnityGLTF 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。