blog games developers documentation portfolio gallery

More in this category:

Rotate()

void Rotate(float degrees)



Rotates the Texture by degrees counter clockwise (use negative value for clockwise rotation).

Although you can use any float value for degrees, using a multitude of 90 will cause the rotation to take place a little faster, because it will use a simpler rotating method.

Example:

if(GUI.Button(new Rect(0,0,200,25), "Rotate 45 degrees clockwise")) {
myTexture.Rotate(-45f); // negative value for clockwise rotation
}

Note that the size of the new image will change due to the rotation.

If you use a Texture2D with a format that supports alpha, the unused pixels will be transparent.

If you use an image format that doesn't support alpha (see import settings of your texture), the unused space of the new texture will be filled with black pixels.
Rotating non-transparent texture.






follow us