Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporting .glb file in a WebGL build in unity #625

Closed
PaulYoSwek opened this issue Jun 29, 2023 · 4 comments
Closed

Exporting .glb file in a WebGL build in unity #625

PaulYoSwek opened this issue Jun 29, 2023 · 4 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@PaulYoSwek
Copy link

When trying to export my object that is placed inside a scene in Unity it never returns a success at all.
The object I'm trying to export is just a simple cube.

Note that it does work in editor but not in a build (WebGL build).

The path looks like this: /idbfs/e43848a1f09e340efa47c9c532e0b2ca/test.glb

My code:

    public async void AdvancedExport()
    {
        var path = Application.persistentDataPath + "/test.glb";

        var exportSettings = new ExportSettings
        {
            Format = GltfFormat.Binary,
            FileConflictResolution = FileConflictResolution.Overwrite,
        };

        var export = new GameObjectExport(exportSettings);

        var rootLevelNodes = GameObject.FindGameObjectsWithTag("ExportMe");

        export.AddScene(rootLevelNodes, "My new glTF scene");

        var success = await export.SaveToFileAndDispose(path);

        Debug.Log("Success: " + success);
    }

The debug message success never gets called

@PaulYoSwek PaulYoSwek added the bug Something isn't working label Jun 29, 2023
@FernandoVillanuevaPadrones

I am having the same issue. I think that it is because webgl does not support await/async calls. There is a package called UniTask that allows await to work but gltffast scripts cannot be modified so I do not what to do

@dkgupta2302
Copy link

Anyone found solution for webGL export with async/await? I am also facing same issue

@atteneder
Copy link
Owner

Fix is coming soon.

I looked at it and found out it hangs whenever Stream.FlushAsync is called in GltfWriter. Using Flush (non async) in WebGL only seems to fix it.

Needle-Mirror-Bot pushed a commit to needle-mirror/com.unity.cloud.gltfast that referenced this issue Sep 6, 2024
## [6.8.0] - 2024-09-05

### Added
- (Import) Setting to create textures readable. This allows users to access resulting textures from their scripts.
- (Export) Non-readable meshes can be exported as well now.
- (Export) Added support for exporting meshes with vertex compression enabled (effectively converting 16-bit float positions/normals/tangents/texture coordinates to 32-bit floats).
- (Export) [Buffer view targets](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#_bufferview_target) are set properly now.
- (Import) Support for mesh primitive modes `TRIANGLE_STRIP` and `TRIANGLE_FAN` (thanks [Hexer611][Hexer611] for [#22](Unity-Technologies/com.unity.cloud.gltfast#22))

### Fixed
- (Export) Writing to files on the web via IndexedDB now works (fixes [#625](atteneder/glTFast#625))
- (Export) test results are validated again.
- (Export) Removed expendable JSON content when exporting unlit materials without color or texture applied.
- Primitve mode LINE_LOOP works as expected (thanks [Hexer611][Hexer611] for [#22](Unity-Technologies/com.unity.cloud.gltfast#22)).
- (Test) Fail export test if glTF JSON contains unexpected or misses expected properties.
- Increased resilience against invalid animation data.
- Broken link in `CONTRIBUTING.md` (thanks [Hexer611][Hexer611] for [#22](Unity-Technologies/com.unity.cloud.gltfast#23)).
- Loading glTFs with unknown texture extensions (e.g. WebP, `EXT_texture_webp`) now works (fixes [#705](atteneder/glTFast#705)).
@atteneder atteneder added this to the 6.8.0 milestone Sep 6, 2024
@atteneder
Copy link
Owner

Fix was released in glTFast 6.8.0.

@atteneder atteneder self-assigned this Sep 6, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants