[SOLVED]GUITexture rotation

Hi, all

I creating main menu for our game and I need rotation some elements, but rotation for GUITexture doesn’t work.

if…

void Update () {
 transform.Rotate(0.0f, 0.0f, 10.0f); 
}

We have not any movement.

if…

void Update () {
 transform.Translate(0.005f, 0.0f, 0.0f); 
 transform.Rotate(0.0f, 0.0f, 10.0f); 
}

We have some progress, but not we want exactly.

Thank you.

Correct, GUITextures do not support rotation.

–Eric

What can I use instead of GUITextures?

You can use GUIUtility.RotateAroundPivot to rotate a GUI.Label.

I need rotate a sprite…

void OnGUI () 
{
  GUIUtility.RotateAroundPivot (10.0f, new Vector2(240.0f, 160.0f)); 
  GUI.DrawTexture(new Rect(0.0f, 0.0f, 480.0f, 320.0f), BGTexture, ScaleMode.StretchToFill, true, 0); 
}

I has used that code and it is working.

Thank all. :slight_smile:

hmm, is there a special reason that GuiTexture can´t to rotate?.. looks like a bit weird…

Not sure but maybe there is a easier way to do it…

not to using GUITexture, just using a plane, apply a texture to it, add a camera and set it to orto, and render only the object you want to rotate…

using guitexture for sprites is a totally horrible idea anyway.

It won’t batch, you can’t do uv animations etc, many good reasons to not even consider it.

Use a mesh based system for sprites and alike, if you don’t want to start at 0, use SpriteManager1, if you want a cool editor, animation etc, then invest into Sprite Manager 2 :slight_smile:

This essentially makes my GUITexture rotate properly. The solution is more complex than a .rotation property for a reason. Make sure to define “myRotatingTexture” using your own methods (Resources.Load or WWW or whatever.) Works great with scanner/radar sweeps, eyeballs, clock hands, map compass, “follow mouse cursor”, etc.

private static int rotationAngle = 0;
     
void onGUI() {

    //do other GUI stuff here - it will not be rotated, example:
    //GUI.Label(new Rect(0,0,Screen.width,100), "Hello World");

    //rotating 256x256 GUITexture in a GUI Group:
    GUI.BeginGroup(new Rect(0,0,Screen.width,Screen.height));
    rotationAngle += 5;
    GUIUtility.RotateAroundPivot(rotationAngle , new Vector2(Screen.width/2, Screen.height/2));
    GUI.DrawTexture(new Rect(Screen.width/2 - 128, Screen.height/2 - 128, 256, 256), myRotatingTexture);
    GUI.EndGroup();
}

I’m having some trouble with guiutility.rotatearoundpivot… could you please help me? Thank you!

@Dreamora GUITexture have an advantage against Canvas and any other newer GUI based system…
the advantage is that all GUITextures will match any sort of resolution and aspect ration, even if you anímate it with Transform… i tried a lot with canvas and ngui for this with no result… the animated (transform transition) sprite gets out of bounds when aspect ratio switches…

This 1:50 (time) video explains it… may i´m bad?