Version: 2021.2
public Color GetPixel (CubemapFace face, int x, int y, int mip= 0);

参数

face The Cubemap face to reference.
mip Mip level to sample, must be in the range [0, mipCount[.
x The X-axis pixel coordinate.
y The Y-axis pixel coordinate.

返回

Color The pixel requested.

描述

Returns pixel color at coordinates (face, mip, x, y).

如果这些像素坐标超出边界(大于宽度/高度或小于 0), 则将被限制或者将根据该纹理的包裹模式进行重复。

纹理必须在导入设置中设置 Is Readable 标志,否则此方法将失败。在使用 Crunch 纹理压缩的纹理上,GetPixel 不可用。

using UnityEngine;

public class Example : MonoBehaviour { public Cubemap texture;

void Start() { // prints the color of the pixel at (0,0) of the +X face Debug.Log(texture.GetPixel(CubemapFace.PositiveX, 0, 0)); } }