Unity 6.3
0 онлайн 69 гостей 3 в системе
Вход

CubemapArray.GetPixels32

Declaration

public Color32[] GetPixels32(CubemapFace face, int arrayElement, int miplevel);
public Color32[] GetPixels32(CubemapFace face, int arrayElement);

Параметры

Параметр Описание
лицо CubemapFace для чтения пиксельных данных.
arrayElement Сегмент массива, из которого будут считываться пиксельные данные.
мипуровень Уровень mipmap для получения. Диапазон 0 через текстуру Texture.mipmapCount. Значение по умолчанию 0.

Возвращаемое значение

Color32[] Массив, содержащий цвета пикселей.

Описание

Получает данные цвета пикселей для уровня mipmap поверхности слоя в виде структур Color32.

Этот метод получает данные пикселей из текстуры в памяти CPU. Texture.isReadable должно быть true.

Массив содержит пиксели строка за строкой, начиная с нижнего левого угла текстуры лица. Размер массива равен ширине × высоте уровня mipmap.

Каждый пиксель является Color32 struct. GetPixels32 может быть медленнее, чем некоторые другие методы текстуры, потому что он преобразует формат текстуры использует в Color32. Чтобы получить данные пикселей быстрее, используйте GetPixelData вместо этого.

Если GetPixels32 не удаётся, Unity вызывает исключение. GetPixels32 может завершиться неудачей, если массив содержит слишком много данных. GetPixelData вместо очень больших текстур.

using UnityEngine;

public class CubemapArrayExample : MonoBehaviour { public CubemapArray source; public CubemapArray destination;

void Start() { // Get a copy of the color data from the source CubemapArray, in lower-precision int format. // Each element in the array represents the color data for an individual pixel. CubemapFace sourceFace = CubemapFace.PositiveX; int sourceSlice = 0; int sourceMipLevel = 0; Color32[] pixels = source.GetPixels32(sourceFace, sourceSlice, sourceMipLevel);

// If required, manipulate the pixels before applying them to the destination texture. // This example code reverses the array, which rotates the image 180 degrees. System.Array.Reverse(pixels, 0, pixels.Length);

// Set the pixels of the destination CubemapArray. CubemapFace destinationFace = CubemapFace.PositiveX; int destinationSlice = 0; int destinationMipLevel = 0; destination.SetPixels32(pixels, destinationFace, destinationSlice, destinationMipLevel);

// Apply changes to the destination CubemapArray, which uploads its data to the GPU. destination.Apply(); } }

Дополнительные ресурсы: ,GetPixels,, ,GetPixelData,, ,SetPixels32,, ,Graphics.CopyTexture,.