Legacy Documentation: Version 2018.1 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

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

Texture2D.GetPixelBilinear

public Color GetPixelBilinear(float x, float y);

Description

Returns filtered pixel color at normalized coordinates (u, v).

Coordinates u and v go from 0.0 to 1.0, just like UV coordinates in meshes. If coordinates are out of bounds (larger than 1.0 or smaller than 0.0), they will be clamped or repeated based on the texture's wrap mode.

Texture coordinates start at lower left corner. UV of (0,0) lands exactly on the bottom left texel; and UV of ((width-1)/width, (height-1)/height) lands exactly on the top right texel.

Returned pixel color is bilinearly filtered.

The texture must have the Read/Write Enabled flag set in the import settings, otherwise this function will fail. GetPixelBilinear is not available on Textures using Crunch texture compression.

See Also: GetPixel.

no example available in C#

See Also: GetPixel.

Did you find this page useful? Please give it a rating: