public InternalObjectBase(IntPtr pointer) { if (pointer == IntPtr.Zero) { throw new NullReferenceException(); } myGcHandle = UnityInternals.gchandle_new(pointer, false); }
public static Il2CppSystem.Type TypeFromPointer(IntPtr classPointer, string typeName = "<unknown type>") { if (classPointer == IntPtr.Zero) { throw new ArgumentException($"{typeName} does not have a corresponding internal class pointer"); } var il2CppType = UnityInternals.class_get_type(classPointer); if (il2CppType == IntPtr.Zero) { throw new ArgumentException($"{typeName} does not have a corresponding class type pointer"); } return(Il2CppSystem.Type.internal_from_handle(il2CppType)); }
private static unsafe string BuildMessage(IntPtr exception) { if (ParseMessageHook != null) { return(ParseMessageHook(exception)); } if (ourMessageBytes == null) { ourMessageBytes = new byte[65536]; fixed(byte *message = ourMessageBytes) UnityInternals.il2cpp_format_exception(exception, message, ourMessageBytes.Length); string builtMessage = Encoding.UTF8.GetString(ourMessageBytes, 0, Array.IndexOf(ourMessageBytes, (byte)0)); fixed(byte *message = ourMessageBytes) UnityInternals.il2cpp_format_stack_trace(exception, message, ourMessageBytes.Length); builtMessage += "\n" + Encoding.UTF8.GetString(ourMessageBytes, 0, Array.IndexOf(ourMessageBytes, (byte)0)); return(builtMessage); }