forked from Unity-Technologies/UnityDataTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssetBundle.cs
More file actions
61 lines (51 loc) · 1.86 KB
/
Copy pathAssetBundle.cs
File metadata and controls
61 lines (51 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System.Collections.Generic;
using UnityDataTools.FileSystem.TypeTreeReaders;
namespace UnityDataTools.Analyzer.SerializedObjects;
public class AssetBundle
{
public string Name { get; init; }
public IReadOnlyList<Asset> Assets { get; init; }
public IReadOnlyList<PPtr> PreloadTable { get; init; }
public bool IsSceneAssetBundle { get; init; }
public class Asset
{
public string Name { get; init; }
public PPtr PPtr { get; init; }
public int PreloadIndex { get; init; }
public int PreloadSize { get; init; }
private Asset() {}
public static Asset Read(RandomAccessReader reader)
{
return new Asset()
{
Name = reader["first"].GetValue<string>(),
PPtr = PPtr.Read(reader["second"]["asset"]),
PreloadIndex = reader["second"]["preloadIndex"].GetValue<int>(),
PreloadSize = reader["second"]["preloadSize"].GetValue<int>()
};
}
}
private AssetBundle() {}
public static AssetBundle Read(RandomAccessReader reader)
{
var name = reader["m_Name"].GetValue<string>();
var assets = new List<Asset>(reader["m_Container"].GetArraySize());
var preloadTable = new List<PPtr>(reader["m_PreloadTable"].GetArraySize());
var isSceneAssetBundle = reader["m_IsStreamedSceneAssetBundle"].GetValue<bool>();
foreach (var pptr in reader["m_PreloadTable"])
{
preloadTable.Add(PPtr.Read(pptr));
}
foreach (var asset in reader["m_Container"])
{
assets.Add(Asset.Read(asset));
}
return new AssetBundle()
{
Name = name,
Assets = assets,
PreloadTable = preloadTable,
IsSceneAssetBundle = isSceneAssetBundle
};
}
}