Test の Dispose が足りないところを修正

This commit is contained in:
ousttrue
2022-01-26 14:17:59 +09:00
parent 163308e2f4
commit 62356cb57e
6 changed files with 43 additions and 41 deletions

View File

@@ -137,30 +137,32 @@ namespace UniGLTF
: MeshExporter_SharedVertexBuffer.Export(data, unityMesh, Materials, axisInverter, meshExportSettings)
;
var parsed = GltfData.CreateFromGltfDataForTest(data.GLTF, data.BinBytes);
using (var parsed = GltfData.CreateFromGltfDataForTest(data.GLTF, data.BinBytes))
{
var indices = parsed.GetIndices(gltfMesh.primitives[0].indices);
Assert.AreEqual(0, indices[0]);
Assert.AreEqual(1, indices[1]);
Assert.AreEqual(5, indices[2]);
Assert.AreEqual(5, indices[3]);
Assert.AreEqual(1, indices[4]);
Assert.AreEqual(4, indices[5]);
}
{
var indices = parsed.GetIndices(gltfMesh.primitives[1].indices);
Assert.AreEqual(1, indices[0]);
Assert.AreEqual(2, indices[1]);
Assert.AreEqual(4, indices[2]);
Assert.AreEqual(4, indices[3]);
Assert.AreEqual(2, indices[4]);
Assert.AreEqual(3, indices[5]);
}
{
var indices = parsed.GetIndices(gltfMesh.primitives[0].indices);
Assert.AreEqual(0, indices[0]);
Assert.AreEqual(1, indices[1]);
Assert.AreEqual(5, indices[2]);
Assert.AreEqual(5, indices[3]);
Assert.AreEqual(1, indices[4]);
Assert.AreEqual(4, indices[5]);
}
var positions = parsed.GetArrayFromAccessor<Vector3>(gltfMesh.primitives[0].attributes.POSITION);
Assert.AreEqual(6, positions.Length);
{
var indices = parsed.GetIndices(gltfMesh.primitives[1].indices);
Assert.AreEqual(1, indices[0]);
Assert.AreEqual(2, indices[1]);
Assert.AreEqual(4, indices[2]);
Assert.AreEqual(4, indices[3]);
Assert.AreEqual(2, indices[4]);
Assert.AreEqual(3, indices[5]);
}
var positions = parsed.GetArrayFromAccessor<Vector3>(gltfMesh.primitives[0].attributes.POSITION);
Assert.AreEqual(6, positions.Length);
}
}
[Test]

View File

@@ -88,10 +88,7 @@ namespace UniGLTF
return;
}
// parse
var data = new GlbFileParser(path.FullName).Parse();
// load
using (var data = new GlbFileParser(path.FullName).Parse())
using (var context = new ImporterContext(data))
{
var instance = context.Load();

View File

@@ -115,9 +115,7 @@ namespace UniGLTF
}
// parse
var parsed = GltfData.CreateFromExportForTest(data);
// import
using (var parsed = GltfData.CreateFromExportForTest(data))
using (var context = new ImporterContext(parsed))
using (var loaded = context.Load())
{

View File

@@ -21,13 +21,15 @@ namespace VRM
static GameObject Load(byte[] bytes, string path)
{
var gltf = new GlbLowLevelParser(path, bytes).Parse();
var data = new VRMData(gltf);
using (var loader = new VRMImporterContext(data))
using (var gltf = new GlbLowLevelParser(path, bytes).Parse())
{
var loaded = loader.Load();
loaded.ShowMeshes();
return loaded.gameObject;
var data = new VRMData(gltf);
using (var loader = new VRMImporterContext(data))
{
var loaded = loader.Load();
loaded.ShowMeshes();
return loaded.gameObject;
}
}
}

View File

@@ -40,14 +40,16 @@ namespace UniVRM10.Test
Debug.Log($"load: {path}");
Assert.IsTrue(Vrm10Data.TryParseOrMigrate(path, true, out Vrm10Data result));
using (result)
{
var go = BuildGameObject(result, true);
Debug.Log(go);
var go = BuildGameObject(result, true);
Debug.Log(go);
// export
var vrmBytes = Vrm10Exporter.Export(go, new EditorTextureSerializer());
// export
var vrmBytes = Vrm10Exporter.Export(go, new EditorTextureSerializer());
Debug.Log($"export {vrmBytes.Length} bytes");
Debug.Log($"export {vrmBytes.Length} bytes");
}
}
}
}

View File

@@ -198,7 +198,7 @@ namespace UniVRM10
{
try
{
Vrm10Data.TryParseOrMigrate(gltf.FullName, true, out Vrm10Data vrm);
Assert.True(Vrm10Data.TryParseOrMigrate(gltf.FullName, true, out Vrm10Data vrm));
using (vrm)
using (var loader = new Vrm10Importer(vrm))
{
@@ -263,6 +263,7 @@ namespace UniVRM10
public void MigrateMeta()
{
Assert.True(Vrm10Data.TryParseOrMigrate(AliciaPath, true, out Vrm10Data vrm));
vrm.Dispose();
}
}
}