From 00460ea051633cee01b7644fb957f29fd54f46cf Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 15 Apr 2021 14:12:21 +0900 Subject: [PATCH 1/2] =?UTF-8?q?if=E6=96=87=E3=80=80=E9=96=93=E9=81=95?= =?UTF-8?q?=E3=81=84=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/VRM/Runtime/IO/VRMMtoonMaterialImporter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/VRM/Runtime/IO/VRMMtoonMaterialImporter.cs b/Assets/VRM/Runtime/IO/VRMMtoonMaterialImporter.cs index 345c74da3..75470b3c5 100644 --- a/Assets/VRM/Runtime/IO/VRMMtoonMaterialImporter.cs +++ b/Assets/VRM/Runtime/IO/VRMMtoonMaterialImporter.cs @@ -97,7 +97,7 @@ namespace VRM public IEnumerable<(SubAssetKey, TextureImportParam)> EnumerateTexturesForMaterial(GltfParser parser, int i) { // mtoon - if (TryCreateParam(parser, i, out MaterialImportParam param)) + if (!TryCreateParam(parser, i, out MaterialImportParam param)) { // unlit if (!GltfUnlitMaterial.TryCreateParam(parser, i, out param)) From 91c44254fb4a2be0b35b670c3e6a88f67b472b0e Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 15 Apr 2021 14:16:15 +0900 Subject: [PATCH 2/2] =?UTF-8?q?MToonMaterialParamTest=20=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/VRM/Tests/MToonTest.cs | 21 +++++++++++++++++- Assets/VRM/Tests/VRM.Tests.asmdef | 1 + Assets/VRM/Tests/VRMTestAssets.cs | 30 ++++++++++++++++++++++++++ Assets/VRM/Tests/VRMTestAssets.cs.meta | 11 ++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 Assets/VRM/Tests/VRMTestAssets.cs create mode 100644 Assets/VRM/Tests/VRMTestAssets.cs.meta diff --git a/Assets/VRM/Tests/MToonTest.cs b/Assets/VRM/Tests/MToonTest.cs index 747e624b5..c2c651597 100644 --- a/Assets/VRM/Tests/MToonTest.cs +++ b/Assets/VRM/Tests/MToonTest.cs @@ -16,7 +16,7 @@ namespace VRM filterMode = FilterMode.Bilinear, }; - var textureManager = new TextureExporter(AssetTextureUtil.IsTextureEditorAsset ); + var textureManager = new TextureExporter(AssetTextureUtil.IsTextureEditorAsset); var srcMaterial = new Material(Shader.Find("VRM/MToon")); var offset = new Vector2(0.3f, 0.2f); @@ -35,5 +35,24 @@ namespace VRM materialProperties = new System.Collections.Generic.List { vrmMaterial } }); } + + [Test] + public void MToonMaterialParamTest() + { + if (!VRMTestAssets.TryGetPath("Models/VRoid/VictoriaRubin/VictoriaRubin.vrm", out string path)) + { + return; + } + + var parser = new GltfParser(); + parser.ParsePath(path); + + var importer = new VRMImporterContext(parser, null); + + var materialImporter = new VRMMtoonMaterialImporter(importer.VRM); + + Assert.AreEqual(73, parser.GLTF.materials.Count); + Assert.True(materialImporter.TryCreateParam(parser, 0, out MaterialImportParam param)); + } } } diff --git a/Assets/VRM/Tests/VRM.Tests.asmdef b/Assets/VRM/Tests/VRM.Tests.asmdef index f7e300683..92d27823b 100644 --- a/Assets/VRM/Tests/VRM.Tests.asmdef +++ b/Assets/VRM/Tests/VRM.Tests.asmdef @@ -3,6 +3,7 @@ "references": [ "VRM", "UniGLTF", + "UniGLTF.Editor", "MeshUtility", "MeshUtility.Editor", "VRMShaders.GLTF.IO.Runtime", diff --git a/Assets/VRM/Tests/VRMTestAssets.cs b/Assets/VRM/Tests/VRMTestAssets.cs new file mode 100644 index 000000000..807abe90b --- /dev/null +++ b/Assets/VRM/Tests/VRMTestAssets.cs @@ -0,0 +1,30 @@ +using System.IO; + +namespace VRM +{ + public static class VRMTestAssets + { + public static bool TryGetPath(string relative, out string path) + { + var env = System.Environment.GetEnvironmentVariable("VRM_TEST_MODELS"); + if (string.IsNullOrEmpty(env)) + { + path = default; + return false; + } + var root = new DirectoryInfo(env); + if (!root.Exists) + { + path = default; + return false; + } + + path = Path.Combine(root.FullName, relative); + if (!File.Exists(path)) + { + return false; + } + return true; + } + } +} diff --git a/Assets/VRM/Tests/VRMTestAssets.cs.meta b/Assets/VRM/Tests/VRMTestAssets.cs.meta new file mode 100644 index 000000000..e5a4274dc --- /dev/null +++ b/Assets/VRM/Tests/VRMTestAssets.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 983946c4f70cc494e87c8c8cf47d2589 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: