diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/IStorage.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/IUrlGetter.cs similarity index 76% rename from Assets/UniGLTF/Runtime/UniGLTF/Format/IStorage.cs rename to Assets/UniGLTF/Runtime/UniGLTF/Format/IUrlGetter.cs index c997c928c..e1052d157 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/Format/IStorage.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/IUrlGetter.cs @@ -2,7 +2,7 @@ using System; namespace UniGLTF { - public interface IStorage + public interface IUrlGetter { ArraySegment Get(string url = default); } diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/IStorage.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/Format/IUrlGetter.cs.meta similarity index 83% rename from Assets/UniGLTF/Runtime/UniGLTF/Format/IStorage.cs.meta rename to Assets/UniGLTF/Runtime/UniGLTF/Format/IUrlGetter.cs.meta index d065e98f4..f416db4ca 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/Format/IStorage.cs.meta +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/IUrlGetter.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6e3316b83a7396047839d12538e5db52 +guid: aed87db763d65564e96f23fc8bebd382 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFBuffer.cs b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFBuffer.cs index ed5dbb166..8f5ffe939 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFBuffer.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/Format/glTFBuffer.cs @@ -9,9 +9,9 @@ namespace UniGLTF IBytesBuffer m_buffer; public IBytesBuffer Buffer => m_buffer; - public void OpenStorage(IStorage storage) + public void OpenStorage(IUrlGetter urlGetter) { - m_buffer = new ArraySegmentByteBuffer(storage.Get(uri)); + m_buffer = new ArraySegmentByteBuffer(urlGetter.Get(uri)); } public glTFBuffer() diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/FileSystemStorage.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/FileSystemStorage.cs index d325bdcda..5712f4c95 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/FileSystemStorage.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/FileSystemStorage.cs @@ -4,7 +4,7 @@ using System.IO; namespace UniGLTF { - public class SimpleStorage : IStorage + public class SimpleStorage : IUrlGetter { ArraySegment m_bytes; @@ -28,7 +28,7 @@ namespace UniGLTF } } - public class FileSystemStorage : IStorage + public class FileSystemStorage : IUrlGetter { string m_root; @@ -60,7 +60,7 @@ namespace UniGLTF } } - public class GltfStorage : IStorage + public class GltfStorage : IUrlGetter { glTF _gltf; diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs index 886dcbbf9..5ce28428d 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs @@ -50,40 +50,40 @@ namespace UniGLTF /// /// URI access /// - IStorage _storage; + IUrlGetter _urlGetter; /// /// Migration Flags used by ImporterContext /// public MigrationFlags MigrationFlags { get; } - public GltfData(string targetPath, string json, glTF gltf, IReadOnlyList chunks, IStorage storage, MigrationFlags migrationFlags) + public GltfData(string targetPath, string json, glTF gltf, IReadOnlyList chunks, IUrlGetter urlGetter, MigrationFlags migrationFlags) { TargetPath = targetPath; Json = json; GLTF = gltf; Chunks = chunks; - _storage = storage; + _urlGetter = urlGetter; MigrationFlags = migrationFlags; } public static GltfData CreateFromGltfDataForTest(glTF gltf, ArraySegment bytes = default) { - IStorage storage = null; + IUrlGetter urlGetter = null; if (bytes.Array != null) { - storage = new SimpleStorage(bytes); + urlGetter = new SimpleStorage(bytes); } else { - storage = new GltfStorage(gltf); + urlGetter = new GltfStorage(gltf); } return new GltfData( string.Empty, string.Empty, gltf, new List(), - storage, + urlGetter, new MigrationFlags() ); } @@ -93,7 +93,7 @@ namespace UniGLTF { // TODO: var buffer = GLTF.buffers[bufferIndex]; - return _storage.Get(buffer.uri); + return _urlGetter.Get(buffer.uri); } public ArraySegment GetViewBytes(int bufferView) @@ -266,7 +266,7 @@ namespace UniGLTF } else { - return _storage.Get(image.uri); + return _urlGetter.Get(image.uri); } } diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/Parser/GlbLowLevelParser.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/Parser/GlbLowLevelParser.cs index a0ecdfd51..8c206e782 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/Parser/GlbLowLevelParser.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/Parser/GlbLowLevelParser.cs @@ -71,7 +71,7 @@ namespace UniGLTF return chunks; } - public static GltfData ParseGltf(string path, string json, IReadOnlyList chunks, IStorage storage, MigrationFlags migrationFlags) + public static GltfData ParseGltf(string path, string json, IReadOnlyList chunks, IUrlGetter urlGetter, MigrationFlags migrationFlags) { var GLTF = GltfDeserializer.Deserialize(json.ParseAsJson()); if (GLTF.asset.version != "2.0") @@ -96,10 +96,10 @@ namespace UniGLTF //GLTF.baseDir = System.IO.Path.GetDirectoryName(Path); foreach (var buffer in GLTF.buffers) { - buffer.OpenStorage(storage); + buffer.OpenStorage(urlGetter); } - return new GltfData(path, json, GLTF, chunks, storage, migrationFlags); + return new GltfData(path, json, GLTF, chunks, urlGetter, migrationFlags); } private static void FixMeshNameUnique(glTF GLTF) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/Parser/JsonWithStorageParser.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/Parser/JsonWithStorageParser.cs index 53cb0ebfb..c04d8f2f4 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/Parser/JsonWithStorageParser.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/Parser/JsonWithStorageParser.cs @@ -10,12 +10,12 @@ namespace UniGLTF public sealed class JsonWithStorageParser { private readonly string _json; - private readonly IStorage _storage; - - public JsonWithStorageParser(string json, IStorage storage = null) + private readonly IUrlGetter _storage; + + public JsonWithStorageParser(string json, IUrlGetter urlGetter = null) { _json = json; - _storage = storage ?? new SimpleStorage(new ArraySegment()); + _storage = urlGetter ?? new SimpleStorage(new ArraySegment()); } public GltfData Parse() diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/ZipArchiveStorage.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/ZipArchiveStorage.cs index 9a15ace8b..fe284e16e 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/ZipArchiveStorage.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/ZipArchiveStorage.cs @@ -292,7 +292,7 @@ namespace UniGLTF.Zip } } - class ZipArchiveStorage : IStorage + class ZipArchiveStorage : IUrlGetter { public override string ToString() {