GUI

PowenKo > Unity > GUI > DrawTexture Rotate

January 21, 2012   ·   0 Comments

Screen Shot 2012-01-20 at 11.34.18 PM

using UnityEngine;
using System.Collections;

public class GUIRotate : MonoBehaviour {

    public Texture2D texture = null;
    public float angle = 0;
    public Vector2 size = new Vector2(128, 128);
    Vector2 pos = new Vector2(200, 200);
    Rect rect;
    Vector2 pivot;

    void Start() {

    }

    void OnGUI() {

		Matrix4x4 matrixBackup  = GUI.matrix;

Vector2 pivotPoint2 =new Vector2(0,0); //(Screen.width) - 125, (Screen.height * 0.20) + 100);

GUIUtility.RotateAroundPivot (angle, pivotPoint2);

GUI.depth=149;

Rect myRect =new Rect((Screen.width)/2,30,50,50); //(Screen.width) - 223, (Screen.height * 0.20) + 4, 202, 202);

GUI.DrawTexture (myRect, texture);

GUI.matrix = matrixBackup;

    }
}
    t_x=t_x+4; 
    t_y=t_y+50-2; 
    
    
     var matrixBackup:Matrix4x4  = GUI.matrix;
var thisAngle:float =-13+79.5+79.5; // Time.frameCount * 2;
var pos:Vector2 = Vector2(t_x+CarMetal_Line.width/3,t_y+CarMetal_Line.height/3/2); 
GUIUtility.RotateAroundPivot(thisAngle, pos);
var thisRect:Rect = Rect(t_x,t_y,CarMetal_Line.width/3 ,CarMetal_Line.height/3 );
GUI.DrawTexture(thisRect, CarMetal_Line);      
GUI.matrix = matrixBackup;

shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Unity3D4

Amazon

adsbygoogle

Recent Posts

Categories

Amazon