我正在尝试获取原始图像上特定像素的颜色,但是它不起作用。你能帮忙吗?这是我使用的代码:
public RawImage map;
public void OnPointerClick(PointerEventData eventData)
{
Vector3 localPosition = transform.InverseTransformPoint(eventData.pressPosition);
Color colour = (map.texture as Texture2D).GetPixel(
Mathf.RoundToInt(localPosition.x),
Mathf.RoundToInt(localPosition.y));
Debug.Log(colour);
Clicked();
}
谢谢!