Legacy Documentation: Version 4.6.2
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

ProceduralTexture.GetPixels32

Suggest a change

Success!

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

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public function GetPixels32(x: int, y: int, blockWidth: int, blockHeight: int): Color32[];
public Color32[] GetPixels32(int x, int y, int blockWidth, int blockHeight);
public def GetPixels32(x as int, y as int, blockWidth as int, blockHeight as int) as Color32[]

Parameters

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.

Description

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.