I am making a colour picker that only uses gui elements created in code. It uses the mouse/touch position and GetPixel to get the colour of the selected part of the image.
//Vector2 Pos2 = new Vector2(Input.mousePosition.x - Pos.x, -(Screen.height - Input.mousePosition.y - Pos.y - Size.y));
Vector2 Pos2 = new Vector2(Input.GetTouch(0).position.x - Pos.x, -(Screen.height - Input.GetTouch(0).position.y - Pos.y - Size.y));
Pos2.x = Mathf.Clamp(Pos2.x, 0, Size.x-1);
Pos2.y = Mathf.Clamp(Pos2.y, 0, Size.y-1);
CrosshairPos = new Vector2(Pos2.x - 12, Size.x-Pos2.y - 12);
colour = ColourTex2D.GetPixel((int)(Pos2.x/Size.x * ColourTex2D.width), (int)(Pos2.y/Size.y * ColourTex2D.height));
This works on computers when it is built for PC but if it is set to be android, it crashes. When it is built for android, it opens on the android device and shows the correct crosshair position but the colour variable does not change from white. Is GetPixel compatible with android. How can this be fixed?