Hello guys,
im pretty new to android game development and im not really sure how to debug in a proper way.
It seems to be a bit handy to play with values and checking stuff on the acuall mobile device.
Anyways… Im convertig a Structure to an ByteArray which works well on the Unity Debugger but as soon
as i move the app to the android device, im getting a Object Reference Error within this function:
public static Byte[] StructureToByteArray(Object obj)
{
try
{
Int32 rawsize = Marshal.SizeOf(obj);
IntPtr buffer = Marshal.AllocHGlobal(rawsize);
Marshal.StructureToPtr(obj, buffer, false); // This function throws the exception
Byte[] rawdatas = new Byte[rawsize];
Marshal.Copy(buffer, rawdatas, 0, rawsize);
Marshal.FreeHGlobal(buffer);
return rawdatas;
}
catch (Exception e)
{
UE.Debug.Log(e.Message);
}
return null;
}
I already did a research on google but i dont found threads about marshal issues on android.
The object is not the issue and gets delivered how it should.
My guess: It is may related to the static unsafe void Copy function or some Windows Only Code within this function which can not work on android, but this is above my knowledge…
Can somebody help me with this issue?