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

Add ReplaceResource Method to RuntimeGltfInstance #2131

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

TomMoore515
Copy link
Contributor

This PR introduces the ReplaceResource method to the RuntimeGltfInstance class. This enables resource replacement of Textures, Materials, AnimationClips, and Meshes. The old resource is destroyed after replacement.

In our project we integrated UniVRM for handling VRM imports. In a recent optimization effort we encountered the need to downscale the textures of imported VRMs during runtime. However we ran into issues regarding UniGLTF as the RuntimeGltfInstance class stores textures and other resources in a readonly list with no way to modify the contents from an external class. The ReplaceResource method is our solution to this limitation. By introducing this method, we can effectively modify and replace resources in the readonly list, ensuring efficient memory in our project.

- Enables resource replacement for Texture, Material, AnimationClip, and Mesh
- Provides error handling for null or mismatched types
- Destroys the old resource after replacement
@vrm-github-bot
Copy link
Collaborator

Can one of the admins verify this patch?

Copy link
Contributor

@ousttrue ousttrue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Santarh
Copy link
Contributor

Santarh commented Aug 16, 2023

Jenkins

@ousttrue ousttrue merged commit 9cb64ba into vrm-c:master Aug 16, 2023
1 check passed
@ousttrue
Copy link
Contributor

Thanks for the pull request.
Will be included in the next v0.114

@ousttrue ousttrue added this to the v0.114 update Vrm10Runtime milestone Aug 16, 2023
@TomMoore515
Copy link
Contributor Author

Thanks all 🙏

@TomMoore515 TomMoore515 deleted the unigltf-replace-resource branch August 16, 2023 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants