mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-07-08 05:04:06 -05:00
NativeArray<byte>? やめ。
* コンストラクターで初期化 * Dispose上の方
This commit is contained in:
parent
6dc449a61d
commit
f966abb9e4
|
|
@ -39,32 +39,12 @@ namespace UniGLTF
|
|||
/// </summary>
|
||||
public glTF GLTF { get; }
|
||||
|
||||
public NativeArray<byte>? _bin;
|
||||
|
||||
/// <summary>
|
||||
/// BIN chunk
|
||||
/// > This chunk MUST be the second chunk of the Binary glTF asset
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public NativeArray<byte> Bin
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_bin.HasValue)
|
||||
{
|
||||
// init
|
||||
if (Chunks != null)
|
||||
{
|
||||
if (Chunks.Count >= 2)
|
||||
{
|
||||
_bin = CreateNativeArray(Chunks[1].Bytes);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return _bin.GetValueOrDefault();
|
||||
}
|
||||
}
|
||||
public NativeArray<byte> Bin { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Migration Flags used by ImporterContext
|
||||
|
|
@ -83,6 +63,8 @@ namespace UniGLTF
|
|||
/// <returns></returns>
|
||||
Dictionary<string, NativeArray<byte>> _UriCache = new Dictionary<string, NativeArray<byte>>();
|
||||
|
||||
List<IDisposable> m_disposables = new List<IDisposable>();
|
||||
|
||||
public GltfData(string targetPath, string json, glTF gltf, IReadOnlyList<GlbChunk> chunks, IStorage storage, MigrationFlags migrationFlags)
|
||||
{
|
||||
TargetPath = targetPath;
|
||||
|
|
@ -91,6 +73,25 @@ namespace UniGLTF
|
|||
Chunks = chunks;
|
||||
_storage = storage;
|
||||
MigrationFlags = migrationFlags;
|
||||
|
||||
// init
|
||||
if (Chunks != null)
|
||||
{
|
||||
if (Chunks.Count >= 2)
|
||||
{
|
||||
Bin = CreateNativeArray(Chunks[1].Bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var disposable in m_disposables)
|
||||
{
|
||||
disposable.Dispose();
|
||||
}
|
||||
m_disposables.Clear();
|
||||
_UriCache.Clear();
|
||||
}
|
||||
|
||||
public static GltfData CreateFromExportForTest(ExportingGltfData data)
|
||||
|
|
@ -403,18 +404,5 @@ namespace UniGLTF
|
|||
array.CopyFrom(data);
|
||||
return array;
|
||||
}
|
||||
|
||||
List<IDisposable> m_disposables = new List<IDisposable>();
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var disposable in m_disposables)
|
||||
{
|
||||
disposable.Dispose();
|
||||
}
|
||||
m_disposables.Clear();
|
||||
_UriCache.Clear();
|
||||
_bin = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user