Search Unity

Question Writing to the 24-32 bits of a uint array value using pointers. Possible "Endianess" issues

Discussion in 'Editor & General Support' started by Guedez, Jun 28, 2020.

  1. Guedez

    Guedez

    Joined:
    Jun 1, 2012
    Posts:
    827
    I just fixed a bug that might lead to issues later:
    I just found out the reason it was not working is because I was getting the byte* as
     byte* bendpointer = ((byte*)WildGrassTilePointers.BendBendDirectionNoneNone.ToPointer());
    and should've been instead
     byte* bendpointer = ((byte*)WildGrassTilePointers.BendBendDirectionNoneNone.ToPointer()) + 3;

    Is this architecture dependent? This is the opposite of what I expected. Is this about that whole little endian big endian thing? Should I expect it to only work on computers that have the same 'endianess' of mine?
    How can I ensure that it will work on all machines?