mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-24 23:18:04 -05:00
add VRM_TEST_MODELS
This commit is contained in:
parent
1f9f5e7498
commit
199bc3e170
|
|
@ -6,7 +6,7 @@ using UnityEngine;
|
|||
|
||||
namespace UniGLTF
|
||||
{
|
||||
public class LoadTests
|
||||
public class GltfLoadTests
|
||||
{
|
||||
static IEnumerable<FileInfo> EnumerateGltfFiles(DirectoryInfo dir)
|
||||
{
|
||||
0
Assets/VRM/Tests/Exception.cs
Normal file
0
Assets/VRM/Tests/Exception.cs
Normal file
11
Assets/VRM/Tests/Exception.cs.meta
Normal file
11
Assets/VRM/Tests/Exception.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bd80effebd71ba445976e6285b714f1c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
97
Assets/VRM/Tests/VRMLoadTests.cs
Normal file
97
Assets/VRM/Tests/VRMLoadTests.cs
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
using UniGLTF;
|
||||
using UnityEngine;
|
||||
|
||||
namespace VRM
|
||||
{
|
||||
public class VRMLoadTest
|
||||
{
|
||||
static IEnumerable<FileInfo> EnumerateGltfFiles(DirectoryInfo dir)
|
||||
{
|
||||
if (dir.Name == ".git")
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
foreach (var child in dir.EnumerateDirectories())
|
||||
{
|
||||
foreach (var x in EnumerateGltfFiles(child))
|
||||
{
|
||||
yield return x;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var child in dir.EnumerateFiles())
|
||||
{
|
||||
switch (child.Extension.ToLower())
|
||||
{
|
||||
case ".vrm":
|
||||
yield return child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Message(string path, Exception exception)
|
||||
{
|
||||
while (exception.InnerException != null)
|
||||
{
|
||||
exception = exception.InnerException;
|
||||
}
|
||||
|
||||
{
|
||||
Debug.LogError($"LoadError: {path}");
|
||||
Debug.LogException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
static void Load(FileInfo gltf, DirectoryInfo root)
|
||||
{
|
||||
var parser = new GltfParser();
|
||||
try
|
||||
{
|
||||
parser.ParsePath(gltf.FullName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"ParseError: {gltf}");
|
||||
Debug.LogException(ex);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using (var importer = new VRMImporterContext(parser))
|
||||
{
|
||||
importer.Load();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Message(gltf.FullName.Substring(root.FullName.Length), ex);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void VrmTestModelsTests()
|
||||
{
|
||||
var env = System.Environment.GetEnvironmentVariable("VRM_TEST_MODELS");
|
||||
if (string.IsNullOrEmpty(env))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var root = new DirectoryInfo(env);
|
||||
if (!root.Exists)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var gltf in EnumerateGltfFiles(root))
|
||||
{
|
||||
Load(gltf, root);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/VRM/Tests/VRMLoadTests.cs.meta
Normal file
11
Assets/VRM/Tests/VRMLoadTests.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f4a4042cfb50bb84495fd90f548683ca
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in New Issue
Block a user