if it can’t use Marshal class (using System.Runtime.InteropServices) in the web player unity3.0?
but there is no problem in unity2.6
What is the reason?
if it can’t use Marshal class (using System.Runtime.InteropServices) in the web player unity3.0?
but there is no problem in unity2.6
What is the reason?
If that was possible in 2.6, it was definitely a mistake. The webplayer is supposed to be completely isolated from anything outside of the project package - memory and code wise.
if can’t using Marshal Class in web…
Are there any other way to convert byte array to struct?
Look up .NET binary serialisation. This seems a good place to start: Binary Serialization | Microsoft Learn
Binary Serialisation of C#:
using System.Runtime.Serialization.Formatters.Binary;
public static byte[ ] ObjectToBytes( object obj )
{
BinaryFormatter bf = new BinaryFormatter();
MemoryStream stream = new MemoryStream();
try
{
bf.Serialize(stream, obj);
}
catch (Exception ex)
{
Debug.Log(" * ObjectToBytes error: " + ex.Message);
return null;
}
byte[ ] byteContent = stream.ToArray();
return byteContent;
}
but there is another problem: the size of bytes ( result of ObjectToBytes ) is very big ,
is very different with Marshal.StructureToPtr