Merge pull request #874 from ousttrue/fix/VRMMaterialImporter_if

if文の間違いを修正
This commit is contained in:
PoChang007 2021-04-15 14:43:10 +09:00 committed by GitHub
commit ea4e842e72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 2 deletions

View File

@ -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))

View File

@ -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<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));
}
}
}

View File

@ -3,6 +3,7 @@
"references": [
"VRM",
"UniGLTF",
"UniGLTF.Editor",
"MeshUtility",
"MeshUtility.Editor",
"VRMShaders.GLTF.IO.Runtime",

View File

@ -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;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 983946c4f70cc494e87c8c8cf47d2589
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: