Version: 2017.2
public Color32[] GetPixels32 (int x, int y, int blockWidth, int blockHeight);

参数

x X-coord of the top-left corner of the rectangle to grab.
y Y-coord of the top-left corner of the rectangle to grab.
blockWidth Width of rectangle to grab.
blockHeight Height of the rectangle to grab. Get the pixel values from a rectangular area of a ProceduralTexture into an array. The block is specified by its x,y offset in the texture and by its width and height. The block is "flattened" into the array by scanning the pixel values across rows one by one.

描述

Grab pixel values from a ProceduralTexture.

This only works for ProceduralMaterial instances that have been marked as "Readable" and whose texture format is set to RAW.

The correct sequence to use GetPixels32() is:
- Set the ProceduralMaterial "Readable" flag using ProceduralMaterial.isReadable
- Rebuild the ProceduralMaterial's textures using ProceduralMaterial.RebuildTexturesImmediately
- Call GetPixels32().

See Also: ProceduralMaterial.isReadable, ProceduralMaterial.RebuildTexturesImmediately, Texture2D.GetPixels32.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961