- Home /
Question by
dot · Nov 08, 2010 at 02:46 AM ·
scriptingbasicsoperator
question mark in "setPixel" documentation example?
what's the question mark in the code
function Start () { // Create a new texture and assign it to the renderer's material var texture = new Texture2D(128, 128); renderer.material.mainTexture = texture;
// Fill the texture with Sierpinski's fractal pattern!
for (var y : int = 0; y < texture.height; ++y) {
for (var x : int = 0; x < texture.width; ++x) {
var color = (x&y) ? Color.white : Color.gray;
texture.SetPixel (x, y, color);
}
}
// Apply all SetPixel calls
texture.Apply();
}
from unity's documentation on SetPixel? and the colon, in here. does it check (?) if the color on a given place i white, an if it is it switches it(:) with gray? and if so, where could we see more examples of such coding?
Comment
Best Answer
Answer by Eric5h5 · Nov 08, 2010 at 02:54 AM
Ternary operator. It checks (x&y) and assigns white if true or gray if false.