So far I’ve got an android plugin which returns a Java Integer from Android Color. I need to convert this Android Color in Integer format to Unity Color or Unity Color32. I’m really trying to understand the values.
It’s not about the plugin, it was about converting the Android Color (Integer) to Unity Color or Unity Color32.
If you talk about this Color it’s simply:
public static Color32 ConvertAndroidColor(uint aCol)
{
Color32 c;
c.b = (byte)((aCol) & 0xFF);
c.g = (byte)((aCol>>8) & 0xFF);
c.r = (byte)((aCol>>16) & 0xFF);
c.a = (byte)((aCol>>24) & 0xFF);
return c;
}
I actually answered my own question, sorry to waste anyone’s time. I converted android color int to bytes and found it’s actually backwards. blue, green, red, alpha in bytes. To see this for yourself just replace the int with the corresponding color int from Android Color. Color | Android Developers
private int color = -1; // white
Then convert to bytes and print.
byte colorBytes = System.BitConverter.GetBytes (yellow);
print (colorBytes); // and here’s our color32 but backwards