Skip to content

Commit

Permalink
Merge pull request #874 from ousttrue/fix/VRMMaterialImporter_if
Browse files Browse the repository at this point in the history
if文の間違いを修正
  • Loading branch information
PoChang007 authored Apr 15, 2021
2 parents ad9cab7 + 91c4425 commit ea4e842
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Assets/VRM/Runtime/IO/VRMMtoonMaterialImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public bool TryCreateParam(GltfParser parser, int i, out MaterialImportParam par
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))
Expand Down
21 changes: 20 additions & 1 deletion Assets/VRM/Tests/MToonTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void TextureTransformTest()
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);
Expand All @@ -35,5 +35,24 @@ public void TextureTransformTest()
materialProperties = new System.Collections.Generic.List<glTF_VRM_Material> { 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));
}
}
}
1 change: 1 addition & 0 deletions Assets/VRM/Tests/VRM.Tests.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"references": [
"VRM",
"UniGLTF",
"UniGLTF.Editor",
"MeshUtility",
"MeshUtility.Editor",
"VRMShaders.GLTF.IO.Runtime",
Expand Down
30 changes: 30 additions & 0 deletions Assets/VRM/Tests/VRMTestAssets.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
11 changes: 11 additions & 0 deletions Assets/VRM/Tests/VRMTestAssets.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ea4e842

Please sign in to comment.