4
4
using System . Linq ;
5
5
using System . Text ;
6
6
using UnhollowerBaseLib ;
7
+ using UnhollowerBaseLib . Attributes ;
7
8
using UnhollowerRuntimeLib ;
8
9
using UnityEngine ;
9
10
using UnityExplorer . Core . Runtime . Il2Cpp ;
10
11
11
12
namespace UnityExplorer
12
13
{
13
- public class AssetBundle
14
+ public class AssetBundle : UnityEngine . Object
14
15
{
16
+ static AssetBundle ( )
17
+ {
18
+ ClassInjector . RegisterTypeInIl2Cpp < AssetBundle > ( ) ;
19
+ }
20
+
15
21
// ~~~~~~~~~~~~ Static ~~~~~~~~~~~~
16
22
17
23
internal delegate IntPtr d_LoadFromFile ( IntPtr path , uint crc , ulong offset ) ;
18
24
25
+ [ HideFromIl2Cpp ]
19
26
public static AssetBundle LoadFromFile ( string path )
20
27
{
21
28
var iCall = ICallManager . GetICall < d_LoadFromFile > ( "UnityEngine.AssetBundle::LoadFromFile_Internal" ) ;
22
- var ptr = iCall . Invoke ( IL2CPP . ManagedStringToIl2Cpp ( path ) , 0u , 0UL ) ;
29
+ var ptr = iCall ( IL2CPP . ManagedStringToIl2Cpp ( path ) , 0u , 0UL ) ;
23
30
return new AssetBundle ( ptr ) ;
24
31
}
25
-
32
+
26
33
private delegate IntPtr d_LoadFromMemory ( IntPtr binary , uint crc ) ;
27
34
35
+ [ HideFromIl2Cpp ]
28
36
public static AssetBundle LoadFromMemory ( byte [ ] binary , uint crc = 0 )
29
37
{
30
38
var iCall = ICallManager . GetICall < d_LoadFromMemory > ( "UnityEngine.AssetBundle::LoadFromMemory_Internal" ) ;
31
- var ptr = iCall ( ( ( Il2CppStructArray < byte > ) binary ) . Pointer , crc ) ;
39
+ var ptr = iCall ( ( ( Il2CppStructArray < byte > ) binary ) . Pointer , crc ) ;
32
40
return new AssetBundle ( ptr ) ;
33
41
}
34
42
43
+ public delegate IntPtr d_GetAllLoadedAssetBundles_Native ( ) ;
44
+
45
+ [ HideFromIl2Cpp ]
46
+ public static AssetBundle [ ] GetAllLoadedAssetBundles ( )
47
+ {
48
+ var iCall = ICallManager . GetICall < d_GetAllLoadedAssetBundles_Native > ( "UnityEngine.AssetBundle::GetAllLoadedAssetBundles_Native" ) ;
49
+ var ptr = iCall ( ) ;
50
+ if ( ptr == IntPtr . Zero )
51
+ return null ;
52
+ return ( AssetBundle [ ] ) new Il2CppReferenceArray < AssetBundle > ( ptr ) ;
53
+ }
54
+
35
55
// ~~~~~~~~~~~~ Instance ~~~~~~~~~~~~
36
56
37
- private readonly IntPtr m_bundlePtr = IntPtr . Zero ;
57
+ public readonly IntPtr m_bundlePtr = IntPtr . Zero ;
38
58
39
- public AssetBundle ( IntPtr ptr ) { m_bundlePtr = ptr ; }
59
+ public AssetBundle ( IntPtr ptr ) : base ( ptr ) { m_bundlePtr = ptr ; }
40
60
41
61
// LoadAllAssets()
42
62
43
63
internal delegate IntPtr d_LoadAssetWithSubAssets_Internal ( IntPtr _this , IntPtr name , IntPtr type ) ;
44
64
65
+ [ HideFromIl2Cpp ]
45
66
public UnityEngine . Object [ ] LoadAllAssets ( )
46
67
{
47
68
var iCall = ICallManager . GetICall < d_LoadAssetWithSubAssets_Internal > ( "UnityEngine.AssetBundle::LoadAssetWithSubAssets_Internal" ) ;
48
- var ptr = iCall . Invoke ( m_bundlePtr , IL2CPP . ManagedStringToIl2Cpp ( "" ) , Il2CppType . Of < UnityEngine . Object > ( ) . Pointer ) ;
69
+ var ptr = iCall . Invoke ( m_bundlePtr , IL2CPP . ManagedStringToIl2Cpp ( "" ) , UnhollowerRuntimeLib . Il2CppType . Of < UnityEngine . Object > ( ) . Pointer ) ;
49
70
50
71
if ( ptr == IntPtr . Zero )
51
72
return new UnityEngine . Object [ 0 ] ;
@@ -57,10 +78,11 @@ public UnityEngine.Object[] LoadAllAssets()
57
78
58
79
internal delegate IntPtr d_LoadAsset_Internal ( IntPtr _this , IntPtr name , IntPtr type ) ;
59
80
81
+ [ HideFromIl2Cpp ]
60
82
public T LoadAsset < T > ( string name ) where T : UnityEngine . Object
61
83
{
62
84
var iCall = ICallManager . GetICall < d_LoadAsset_Internal > ( "UnityEngine.AssetBundle::LoadAsset_Internal" ) ;
63
- var ptr = iCall . Invoke ( m_bundlePtr , IL2CPP . ManagedStringToIl2Cpp ( name ) , Il2CppType . Of < T > ( ) . Pointer ) ;
85
+ var ptr = iCall . Invoke ( m_bundlePtr , IL2CPP . ManagedStringToIl2Cpp ( name ) , UnhollowerRuntimeLib . Il2CppType . Of < T > ( ) . Pointer ) ;
64
86
65
87
if ( ptr == IntPtr . Zero )
66
88
return null ;
@@ -72,10 +94,11 @@ public T LoadAsset<T>(string name) where T : UnityEngine.Object
72
94
73
95
internal delegate void d_Unload ( IntPtr _this , bool unloadAllLoadedObjects ) ;
74
96
75
- public void Unload ( bool unloadAssets = true )
97
+ [ HideFromIl2Cpp ]
98
+ public void Unload ( bool unloadAllLoadedObjects )
76
99
{
77
100
var iCall = ICallManager . GetICall < d_Unload > ( "UnityEngine.AssetBundle::Unload" ) ;
78
- iCall . Invoke ( this . m_bundlePtr , unloadAssets ) ;
101
+ iCall . Invoke ( this . m_bundlePtr , unloadAllLoadedObjects ) ;
79
102
}
80
103
}
81
104
}
0 commit comments