From e663091fee715c5dbe88cacdd0728b7cef7c5e03 Mon Sep 17 00:00:00 2001 From: amamagi Date: Wed, 11 Jan 2023 11:43:58 +0900 Subject: [PATCH] feat: Add ITextureDeserializer parameter to Vrm10.LoadXXXAsync() and VrmUtility.LoadXXXAsync() --- Assets/VRM/Runtime/IO/VrmUtility.cs | 14 ++++++++++++-- Assets/VRM10/Runtime/IO/Vrm10.cs | 20 +++++++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Assets/VRM/Runtime/IO/VrmUtility.cs b/Assets/VRM/Runtime/IO/VrmUtility.cs index fec35b4d7..19d320b26 100644 --- a/Assets/VRM/Runtime/IO/VrmUtility.cs +++ b/Assets/VRM/Runtime/IO/VrmUtility.cs @@ -15,6 +15,7 @@ namespace VRM IAwaitCaller awaitCaller = null, MaterialGeneratorCallback materialGeneratorCallback = null, MetaCallback metaCallback = null, + ITextureDeserializer textureDeserializer = null, bool loadAnimation = false ) { @@ -39,7 +40,11 @@ namespace VRM { materialGen = materialGeneratorCallback(vrm.VrmExtension); } - using (var loader = new VRMImporterContext(vrm, materialGenerator: materialGen, loadAnimation: loadAnimation)) + using (var loader = new VRMImporterContext( + vrm, + textureDeserializer: textureDeserializer, + materialGenerator: materialGen, + loadAnimation: loadAnimation)) { if (metaCallback != null) { @@ -67,6 +72,7 @@ namespace VRM IAwaitCaller awaitCaller = null, MaterialGeneratorCallback materialGeneratorCallback = null, MetaCallback metaCallback = null, + ITextureDeserializer textureDeserializer = null, bool loadAnimation = false ) { @@ -91,7 +97,11 @@ namespace VRM { materialGen = materialGeneratorCallback(vrm.VrmExtension); } - using (var loader = new VRMImporterContext(vrm, materialGenerator: materialGen, loadAnimation: loadAnimation)) + using (var loader = new VRMImporterContext( + vrm, + textureDeserializer: textureDeserializer, + materialGenerator: materialGen, + loadAnimation: loadAnimation)) { if (metaCallback != null) { diff --git a/Assets/VRM10/Runtime/IO/Vrm10.cs b/Assets/VRM10/Runtime/IO/Vrm10.cs index c6b34fbe5..b1b433fe8 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10.cs @@ -31,6 +31,7 @@ namespace UniVRM10 /// the flag of generating the control rig provides bone manipulation unified between models. /// if true, show meshes when loaded. /// this loader use specified await strategy. + /// this loader use specified texture deserialization strategy. /// this loader use specified material generation strategy. /// return callback that notify meta information before loading. /// CancellationToken @@ -41,6 +42,7 @@ namespace UniVRM10 ControlRigGenerationOption controlRigGenerationOption = ControlRigGenerationOption.Generate, bool showMeshes = true, IAwaitCaller awaitCaller = null, + ITextureDeserializer textureDeserializer = null, IMaterialDescriptorGenerator materialGenerator = null, VrmMetaInformationCallback vrmMetaInformationCallback = null, CancellationToken ct = default) @@ -59,6 +61,7 @@ namespace UniVRM10 controlRigGenerationOption, showMeshes, awaitCaller, + textureDeserializer, materialGenerator, vrmMetaInformationCallback, ct); @@ -75,6 +78,7 @@ namespace UniVRM10 /// the flag of generating the control rig provides bone manipulation unified between models. /// if true, show meshes when loaded. /// this loader use specified await strategy. + /// this loader use specified texture deserialization strategy. /// this loader use specified material generation strategy. /// return callback that notify meta information before loading. /// CancellationToken @@ -85,6 +89,7 @@ namespace UniVRM10 ControlRigGenerationOption controlRigGenerationOption = ControlRigGenerationOption.Generate, bool showMeshes = true, IAwaitCaller awaitCaller = null, + ITextureDeserializer textureDeserializer = null, IMaterialDescriptorGenerator materialGenerator = null, VrmMetaInformationCallback vrmMetaInformationCallback = null, CancellationToken ct = default) @@ -103,6 +108,7 @@ namespace UniVRM10 controlRigGenerationOption, showMeshes, awaitCaller, + textureDeserializer, materialGenerator, vrmMetaInformationCallback, ct); @@ -115,6 +121,7 @@ namespace UniVRM10 ControlRigGenerationOption controlRigGenerationOption, bool showMeshes, IAwaitCaller awaitCaller, + ITextureDeserializer textureDeserializer, IMaterialDescriptorGenerator materialGenerator, VrmMetaInformationCallback vrmMetaInformationCallback, CancellationToken ct) @@ -133,6 +140,7 @@ namespace UniVRM10 controlRigGenerationOption, showMeshes, awaitCaller, + textureDeserializer, materialGenerator, vrmMetaInformationCallback, ct); @@ -158,6 +166,7 @@ namespace UniVRM10 controlRigGenerationOption, showMeshes, awaitCaller, + textureDeserializer, materialGenerator, vrmMetaInformationCallback, ct); @@ -181,6 +190,7 @@ namespace UniVRM10 ControlRigGenerationOption controlRigGenerationOption, bool showMeshes, IAwaitCaller awaitCaller, + ITextureDeserializer textureDeserializer, IMaterialDescriptorGenerator materialGenerator, VrmMetaInformationCallback vrmMetaInformationCallback, CancellationToken ct) @@ -206,6 +216,7 @@ namespace UniVRM10 controlRigGenerationOption, showMeshes, awaitCaller, + textureDeserializer, materialGenerator, vrmMetaInformationCallback, ct); @@ -216,6 +227,7 @@ namespace UniVRM10 ControlRigGenerationOption controlRigGenerationOption, bool showMeshes, IAwaitCaller awaitCaller, + ITextureDeserializer textureDeserializer, IMaterialDescriptorGenerator materialGenerator, VrmMetaInformationCallback vrmMetaInformationCallback, CancellationToken ct) @@ -243,6 +255,7 @@ namespace UniVRM10 controlRigGenerationOption, showMeshes, awaitCaller, + textureDeserializer, materialGenerator, vrmMetaInformationCallback, ct); @@ -260,6 +273,7 @@ namespace UniVRM10 ControlRigGenerationOption controlRigGenerationOption, bool showMeshes, IAwaitCaller awaitCaller, + ITextureDeserializer textureDeserializer, IMaterialDescriptorGenerator materialGenerator, VrmMetaInformationCallback vrmMetaInformationCallback, CancellationToken ct) @@ -275,7 +289,11 @@ namespace UniVRM10 throw new ArgumentNullException(nameof(vrm10Data)); } - using (var loader = new Vrm10Importer(vrm10Data, materialGenerator: materialGenerator, controlRigInitialRotations: controlRigGenerationOption.ToInitialRotations())) + using (var loader = new Vrm10Importer( + vrm10Data, + textureDeserializer: textureDeserializer, + materialGenerator: materialGenerator, + controlRigInitialRotations: controlRigGenerationOption.ToInitialRotations())) { // 1. Load meta information if callback was available. if (vrmMetaInformationCallback != null)