Skip to content

Commit

Permalink
Revert Il2CppObjectPool.cs and change incorrect typeof
Browse files Browse the repository at this point in the history
  • Loading branch information
aceman1209 committed Jan 4, 2025
1 parent eafd7aa commit 78a13d9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Il2CppInterop.Runtime/InteropTypes/Il2CppObjectBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public T Unbox<T>() where T : unmanaged
}

private static readonly Type[] _intPtrTypeArray = { typeof(IntPtr) };
private static readonly MethodInfo _getUninitializedObject = typeof(RuntimeHelpers).GetMethod(nameof(FormatterServices.GetUninitializedObject))!;
private static readonly MethodInfo _getUninitializedObject = typeof(FormatterServices).GetMethod(nameof(FormatterServices.GetUninitializedObject))!;
private static readonly MethodInfo _getTypeFromHandle = typeof(Type).GetMethod(nameof(Type.GetTypeFromHandle))!;
private static readonly MethodInfo _createGCHandle = typeof(Il2CppObjectBase).GetMethod(nameof(CreateGCHandle), BindingFlags.Instance | BindingFlags.NonPublic)!;
private static readonly FieldInfo _isWrapped = typeof(Il2CppObjectBase).GetField(nameof(isWrapped), BindingFlags.Instance | BindingFlags.NonPublic)!;
Expand Down
10 changes: 3 additions & 7 deletions Il2CppInterop.Runtime/Runtime/Il2CppObjectPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,10 @@ public static T Get<T>(IntPtr ptr)
var newObj = Il2CppObjectBase.InitializerStore<T>.Initializer(ptr);
unsafe
{
var il2CppClass = (Il2CppClass*)Il2CppClassPointerStore<T>.NativeClassPtr;
if (il2CppClass != null)
var nativeClassStruct = UnityVersionHandler.Wrap((Il2CppClass*)Il2CppClassPointerStore<T>.NativeClassPtr);
if (!nativeClassStruct.HasFinalize)
{
var nativeClassStruct = UnityVersionHandler.Wrap(il2CppClass);
if (!nativeClassStruct.HasFinalize)
{
Il2CppSystem.GC.ReRegisterForFinalize(newObj as Object ?? new Object(ptr));
}
Il2CppSystem.GC.ReRegisterForFinalize(newObj as Object ?? new Object(ptr));
}
}

Expand Down

0 comments on commit 78a13d9

Please sign in to comment.