Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Close Submission failedFor some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Close Your name Your email Suggestion* Declarationpublic void
SetPixels(Color[]
colors,
CubemapFace face, int
miplevel);
Declarationpublic void
SetPixels(Color[]
colors,
CubemapFace face);
Parameters Parameter Description colors The array of pixel colours to use. This is a 2D image flattened to a 1D array. miplevel The mipmap level to writecolors
to. The range is 0
through the texture's Texture.mipmapCount. The default value is 0
. face The CubemapFace to write colors
to. Description
Sets the pixel colors of an entire mipmap level of a face.
This method sets pixel data for the texture in CPU memory. Texture.isReadable must be true
, and you must call Apply after SetPixels
to upload the changed pixels to the GPU.
Apply is an expensive operation because it copies all the pixels in the texture even if you've only changed some of the pixels, so change as many pixels as possible before you call it.
colors
must contain the pixels row by row, starting at the bottom left of the face texture. The size of the array must be the width à height of the mipmap level.
A single call to SetPixels
is usually faster than multiple calls to SetPixel, especially for large textures.
SetPixels
might be slower than some other texture methods because it converts the Color struct into the format the texture uses. To set pixel data more quickly, use SetPixelData instead.
You can use SetPixels
with the following texture formats:
For all other formats, SetPixels
fails. Unity throws an exception when SetPixels
fails.
Additional resources: GetPixels, SetPixelData, Apply, mipmapCount.
// copy a texture to the +X face of a cubemapusing UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { public Cubemap c; public Texture2D t; private Color[] CubeMapColors;
void Example() { CubeMapColors = t.GetPixels(); c.SetPixels(CubeMapColors, CubemapFace.PositiveX); c.Apply(); } }
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4