答案 0 :(得分:1)
尝试使用此代码从点击位置获取纹理并获取命中位置的像素颜色:
Vector2 pos = Input.mousePosition;
Camera cam = Camera.mainCamera;
Ray ray = cam.ScreenPointToRay(pos);
Physics.Raycast(cam.transform.position, ray.direction, out hitPoint, 10000.0f);
Color mycolor;
if(hitPoint.collider) {
Texture2D tex = (Texture2D) hitPoint.collider.gameObject.renderer.material.mainTexture;
mycolor = tex.GetPixelBilinear(hitPoint.textureCoord2.x, hitPoint.textureCoord2.y);
}