face | The face from which pixel data is taken. |
miplevel | Mipmap level for the chosen face. |
Returns pixel colors of a cubemap face.
mipSize=max(1,width>>miplevel)
.The texture must have the Is Readable flag set in the import settings, otherwise this function will fail.Using GetPixels
can be faster than calling GetPixel repeatedly, especially
for large textures. In addition, GetPixels
can access individual mipmap levels.See Also: SetPixels, mipmapCount.// copy the +X face of a cubemap to a texture. var c : Cubemap; var t : Texture2D; private var CubeMapColors : Color[]; CubeMapColors = c.GetPixels(CubemapFace.PositiveX); t.SetPixels(CubeMapColors); t.Apply(); //Apply changes to the copied texture
using UnityEngine; using System.Collections; public class Example : MonoBehaviour { public Cubemap c; public Texture2D t; private Color[] CubeMapColors; void Example() { CubeMapColors = c.GetPixels(CubemapFace.PositiveX); t.SetPixels(CubeMapColors); t.Apply(); } }
import UnityEngine import System.Collections public class Example(MonoBehaviour): public c as Cubemap public t as Texture2D private CubeMapColors as (Color) def Example() as void: CubeMapColors = c.GetPixels(CubemapFace.PositiveX) t.SetPixels(CubeMapColors) t.Apply()