-
Notifications
You must be signed in to change notification settings - Fork 2
/
Il2CppAssetBundleManager.cs
139 lines (119 loc) · 9.71 KB
/
Il2CppAssetBundleManager.cs
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
using Il2CppSystem.IO;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
namespace UnityEngine
{
public class Il2CppAssetBundleManager
{
static Il2CppAssetBundleManager()
{
GetAllLoadedAssetBundles_NativeDelegateField = IL2CPP.ResolveICall<GetAllLoadedAssetBundles_NativeDelegate>("UnityEngine.AssetBundle::GetAllLoadedAssetBundles_Native");
LoadFromFile_InternalDelegateField = IL2CPP.ResolveICall<LoadFromFile_InternalDelegate>("UnityEngine.AssetBundle::LoadFromFile_Internal(System.String,System.UInt32,System.UInt64)");
LoadFromFileAsync_InternalDelegateField = IL2CPP.ResolveICall<LoadFromFileAsync_InternalDelegate>("UnityEngine.AssetBundle::LoadFromFileAsync_Internal");
LoadFromMemory_InternalDelegateField = IL2CPP.ResolveICall<LoadFromMemory_InternalDelegate>("UnityEngine.AssetBundle::LoadFromMemory_Internal");
LoadFromMemoryAsync_InternalDelegateField = IL2CPP.ResolveICall<LoadFromMemoryAsync_InternalDelegate>("UnityEngine.AssetBundle::LoadFromMemoryAsync_Internal");
LoadFromStreamInternalDelegateField = IL2CPP.ResolveICall<LoadFromStreamInternalDelegate>("UnityEngine.AssetBundle::LoadFromStreamInternal");
LoadFromStreamAsyncInternalDelegateField = IL2CPP.ResolveICall<LoadFromStreamAsyncInternalDelegate>("UnityEngine.AssetBundle::LoadFromStreamAsyncInternal");
UnloadAllAssetBundlesDelegateField = IL2CPP.ResolveICall<UnloadAllAssetBundlesDelegate>("UnityEngine.AssetBundle::UnloadAllAssetBundles");
}
public static Il2CppAssetBundle[] GetAllLoadedAssetBundles()
{
if (GetAllLoadedAssetBundles_NativeDelegateField == null)
throw new System.NullReferenceException("The GetAllLoadedAssetBundles_NativeDelegateField cannot be null.");
System.IntPtr intPtr = GetAllLoadedAssetBundles_NativeDelegateField();
Il2CppReferenceArray<Object> refarr = ((intPtr != System.IntPtr.Zero) ? new Il2CppReferenceArray<Object>(intPtr) : null);
if (refarr == null)
throw new System.NullReferenceException("The refarr cannot be null.");
System.Collections.Generic.List<Il2CppAssetBundle> bundlelist = new System.Collections.Generic.List<Il2CppAssetBundle>();
for (int i = 0; i < refarr.Length; i++)
bundlelist.Add(new Il2CppAssetBundle(IL2CPP.Il2CppObjectBaseToPtrNotNull(refarr[i])));
return bundlelist.ToArray();
}
public static Il2CppAssetBundle LoadFromFile(string path) => LoadFromFile(path, 0u, 0UL);
public static Il2CppAssetBundle LoadFromFile(string path, uint crc) => LoadFromFile(path, crc, 0UL);
public static Il2CppAssetBundle LoadFromFile(string path, uint crc, ulong offset)
{
if (string.IsNullOrEmpty(path))
throw new System.ArgumentException("The input asset bundle path cannot be null or empty.");
if (LoadFromFile_InternalDelegateField == null)
throw new System.NullReferenceException("The LoadFromFile_InternalDelegateField cannot be null.");
System.IntPtr intPtr = LoadFromFile_InternalDelegateField(IL2CPP.ManagedStringToIl2Cpp(path), crc, offset);
return ((intPtr != System.IntPtr.Zero) ? new Il2CppAssetBundle(intPtr) : null);
}
public static Il2CppAssetBundleCreateRequest LoadFromFileAsync(string path) => LoadFromFileAsync(path, 0u, 0UL);
public static Il2CppAssetBundleCreateRequest LoadFromFileAsync(string path, uint crc) => LoadFromFileAsync(path, crc, 0UL);
public static Il2CppAssetBundleCreateRequest LoadFromFileAsync(string path, uint crc, ulong offset)
{
if (string.IsNullOrEmpty(path))
throw new System.ArgumentException("The input asset bundle path cannot be null or empty.");
if (LoadFromFileAsync_InternalDelegateField == null)
throw new System.NullReferenceException("The LoadFromFileAsync_InternalDelegateField cannot be null.");
System.IntPtr intPtr = LoadFromFileAsync_InternalDelegateField(IL2CPP.ManagedStringToIl2Cpp(path), crc, offset);
return ((intPtr != System.IntPtr.Zero) ? new Il2CppAssetBundleCreateRequest(intPtr) : null);
}
public static Il2CppAssetBundle LoadFromMemory(Il2CppStructArray<byte> binary) => LoadFromMemory(binary, 0u);
public static Il2CppAssetBundle LoadFromMemory(Il2CppStructArray<byte> binary, uint crc)
{
if (binary == null)
throw new System.ArgumentException("The binary cannot be null or empty.");
if (LoadFromMemory_InternalDelegateField == null)
throw new System.NullReferenceException("The LoadFromMemory_InternalDelegateField cannot be null.");
System.IntPtr intPtr = LoadFromMemory_InternalDelegateField(IL2CPP.Il2CppObjectBaseToPtrNotNull(binary), crc);
return ((intPtr != System.IntPtr.Zero) ? new Il2CppAssetBundle(intPtr) : null);
}
public static Il2CppAssetBundleCreateRequest LoadFromMemoryAsync(Il2CppStructArray<byte> binary) => LoadFromMemoryAsync(binary, 0u);
public static Il2CppAssetBundleCreateRequest LoadFromMemoryAsync(Il2CppStructArray<byte> binary, uint crc)
{
if (binary == null)
throw new System.ArgumentException("The binary cannot be null or empty.");
if (LoadFromMemoryAsync_InternalDelegateField == null)
throw new System.NullReferenceException("The LoadFromMemoryAsync_InternalDelegateField cannot be null.");
System.IntPtr intPtr = LoadFromMemoryAsync_InternalDelegateField(IL2CPP.Il2CppObjectBaseToPtrNotNull(binary), crc);
return ((intPtr != System.IntPtr.Zero) ? new Il2CppAssetBundleCreateRequest(intPtr) : null);
}
public static Il2CppAssetBundle LoadFromStream(Stream stream) => LoadFromStream(stream, 0u, 0u);
public static Il2CppAssetBundle LoadFromStream(Stream stream, uint crc) => LoadFromStream(stream, crc, 0u);
public static Il2CppAssetBundle LoadFromStream(Stream stream, uint crc, uint managedReadBufferSize)
{
if (stream == null)
throw new System.ArgumentException("The stream cannot be null or empty.");
if (LoadFromStreamInternalDelegateField == null)
throw new System.NullReferenceException("The LoadFromStreamInternalDelegateField cannot be null.");
System.IntPtr intPtr = LoadFromStreamInternalDelegateField(IL2CPP.Il2CppObjectBaseToPtrNotNull(stream), crc, managedReadBufferSize);
return ((intPtr != System.IntPtr.Zero) ? new Il2CppAssetBundle(intPtr) : null);
}
public static Il2CppAssetBundleCreateRequest LoadFromStreamAsync(Stream stream) => LoadFromStreamAsync(stream, 0u, 0u);
public static Il2CppAssetBundleCreateRequest LoadFromStreamAsync(Stream stream, uint crc) => LoadFromStreamAsync(stream, crc, 0u);
public static Il2CppAssetBundleCreateRequest LoadFromStreamAsync(Stream stream, uint crc, uint managedReadBufferSize)
{
if (stream == null)
throw new System.ArgumentException("The stream cannot be null or empty.");
if (LoadFromStreamAsyncInternalDelegateField == null)
throw new System.NullReferenceException("The LoadFromStreamAsyncInternalDelegateField cannot be null.");
System.IntPtr intPtr = LoadFromStreamAsyncInternalDelegateField(IL2CPP.Il2CppObjectBaseToPtrNotNull(stream), crc, managedReadBufferSize);
return ((intPtr != System.IntPtr.Zero) ? new Il2CppAssetBundleCreateRequest(intPtr) : null);
}
public static void UnloadAllAssetBundles(bool unloadAllObjects)
{
if (UnloadAllAssetBundlesDelegateField == null)
throw new System.NullReferenceException("The UnloadAllAssetBundlesDelegateField cannot be null.");
UnloadAllAssetBundlesDelegateField(unloadAllObjects);
}
private delegate System.IntPtr GetAllLoadedAssetBundles_NativeDelegate();
private static readonly GetAllLoadedAssetBundles_NativeDelegate GetAllLoadedAssetBundles_NativeDelegateField;
private delegate System.IntPtr LoadFromFile_InternalDelegate(System.IntPtr path, uint crc, ulong offset);
private static readonly LoadFromFile_InternalDelegate LoadFromFile_InternalDelegateField;
private delegate System.IntPtr LoadFromFileAsync_InternalDelegate(System.IntPtr path, uint crc, ulong offset);
private static readonly LoadFromFileAsync_InternalDelegate LoadFromFileAsync_InternalDelegateField;
private delegate System.IntPtr LoadFromMemory_InternalDelegate(System.IntPtr binary, uint crc);
private static readonly LoadFromMemory_InternalDelegate LoadFromMemory_InternalDelegateField;
private delegate System.IntPtr LoadFromMemoryAsync_InternalDelegate(System.IntPtr binary, uint crc);
private static readonly LoadFromMemoryAsync_InternalDelegate LoadFromMemoryAsync_InternalDelegateField;
private delegate System.IntPtr LoadFromStreamInternalDelegate(System.IntPtr stream, uint crc, uint managedReadBufferSize);
private static readonly LoadFromStreamInternalDelegate LoadFromStreamInternalDelegateField;
private delegate System.IntPtr LoadFromStreamAsyncInternalDelegate(System.IntPtr stream, uint crc, uint managedReadBufferSize);
private static readonly LoadFromStreamAsyncInternalDelegate LoadFromStreamAsyncInternalDelegateField;
private delegate System.IntPtr UnloadAllAssetBundlesDelegate(bool unloadAllObjects);
private static readonly UnloadAllAssetBundlesDelegate UnloadAllAssetBundlesDelegateField;
}
}