GlbGltfZipFileParser が AmbiguousGltfFileParser と同じ内容だった。

* GlbGltfZipFileParser 削除
* AmbiguousGltfFileParser を AutoGltfFileParser に改名(うーむ)
This commit is contained in:
ousttrue 2021-09-08 17:41:23 +09:00
parent 75d0c3d507
commit 872888a35a
10 changed files with 14 additions and 50 deletions

View File

@ -52,7 +52,7 @@ namespace UniGLTF
//
// Parse(parse glb, parser gltf json)
//
var data = new AmbiguousGltfFileParser(scriptedImporter.assetPath).Parse();
var data = new AutoGltfFileParser(scriptedImporter.assetPath).Parse();
//

View File

@ -24,7 +24,7 @@ namespace UniGLTF
base.OnEnable();
m_importer = target as GltfScriptedImporter;
m_data = new AmbiguousGltfFileParser(m_importer.assetPath).Parse();
m_data = new AutoGltfFileParser(m_importer.assetPath).Parse();
var materialGenerator = new GltfMaterialDescriptorGenerator();
var materialKeys = m_data.GLTF.materials.Select((_, i) => materialGenerator.Get(m_data, i).SubAssetKey);

View File

@ -24,7 +24,7 @@ namespace UniGLTF
base.OnEnable();
m_importer = target as ZipArchivedGltfScriptedImporter;
m_data = new AmbiguousGltfFileParser(m_importer.assetPath).Parse();
m_data = new AutoGltfFileParser(m_importer.assetPath).Parse();
var materialGenerator = new GltfMaterialDescriptorGenerator();
var materialKeys = m_data.GLTF.materials.Select((_, i) => materialGenerator.Get(m_data, i).SubAssetKey);

View File

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 3a36dcb5732b467598919c0ed66f0c5a
timeCreated: 1624802689

View File

@ -3,14 +3,15 @@
namespace UniGLTF
{
/// <summary>
/// Ambiguous file parser.
/// Auto detection file parser.
/// Determine parsing method from the file extension.
/// Detects `gltf`` zip`, others as` glb`
/// </summary>
public sealed class AmbiguousGltfFileParser
public sealed class AutoGltfFileParser
{
private readonly string _path;
public AmbiguousGltfFileParser(string path)
public AutoGltfFileParser(string path)
{
_path = path;
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 98f146563e4117246b39f51db89de6a3
guid: bc9d157827565c84f9ad41c907fd12e5
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -1,34 +0,0 @@
using System.IO;
namespace UniGLTF
{
/// <summary>
/// Parse file and detect file type by file extension.
/// </summary>
public sealed class GltfZipOrGlbFileParser
{
private readonly string _path;
public GltfZipOrGlbFileParser(string glbFilePath)
{
_path = glbFilePath;
}
public GltfData Parse()
{
var ext = Path.GetExtension(_path).ToLower();
switch (ext)
{
case ".gltf":
return new GltfFileWithResourceFilesParser(_path).Parse();
case ".zip":
return new ZipArchivedGltfFileParser(_path).Parse();
default:
// or glb
return new GlbFileParser(_path).Parse();
}
}
}
}

View File

@ -81,7 +81,7 @@ namespace UniGLTF
GltfData data = null;
try
{
data = new AmbiguousGltfFileParser(gltf.FullName).Parse();
data = new AutoGltfFileParser(gltf.FullName).Parse();
}
catch (Exception ex)
{
@ -127,7 +127,7 @@ namespace UniGLTF
GltfData data = null;
try
{
data = new AmbiguousGltfFileParser(gltf.FullName).Parse();
data = new AutoGltfFileParser(gltf.FullName).Parse();
}
catch (Exception ex)
{
@ -205,7 +205,7 @@ namespace UniGLTF
{
var path = Path.Combine(root.FullName, "DamagedHelmet/glTF-Binary/DamagedHelmet.glb");
var data = new AmbiguousGltfFileParser(path).Parse();
var data = new AutoGltfFileParser(path).Parse();
var matDesc = new GltfMaterialDescriptorGenerator().Get(data, 0);
Assert.AreEqual("Standard", matDesc.ShaderName);

View File

@ -407,7 +407,7 @@ namespace VRM.SimpleViewer
GltfData data;
try
{
data = new GltfZipOrGlbFileParser(path).Parse();
data = new AutoGltfFileParser(path).Parse();
}
catch (Exception ex)
{

View File

@ -425,7 +425,7 @@ namespace UniVRM10.VRM10Viewer
GltfData data;
try
{
data = new GltfZipOrGlbFileParser(path).Parse();
data = new AutoGltfFileParser(path).Parse();
}
catch (Exception ex)
{
@ -439,7 +439,7 @@ namespace UniVRM10.VRM10Viewer
using (var loader = new Vrm10Importer(vrm, materialGenerator: GetVrmMaterialDescriptorGenerator(m_useUrpMaterial.isOn)))
{
// migrate しても thumbnail は同じ
var thumbnail = await loader.LoadVrmThumbnailAsync();
var thumbnail = await loader.LoadVrmThumbnailAsync();
if (vrm.OldMeta != null)
{