- Home /
 
              This post has been wikified, any user with enough reputation can edit it. 
            
 
             
               Question by 
               jmparavicini · Sep 27, 2014 at 01:45 PM · 
                guirotatescale  
              
 
              GUI Rotate and Scale dont work together
Hi everyone so i have a 2 different parts in a script. The first part is to rotate the GUI and it works perfect and the second part is to scale my GUI's and it works great too, but when i add them together just the one part which is under the other part works, like this
part 1 The Rotate 
 
                private var rotAngle : float = 90;
 private var pivotPoint : Vector2;
 
 function OnGUI()
 {
     pivotPoint = Vector2(Screen.width/2,Screen.height/2);
     GUIUtility.RotateAroundPivot (rotAngle, pivotPoint); 
     if(GUI.Button(ResizeGUI(Rect(470, 225, 100, 50)), "Settings"))
     {
         
     }
 }
  
                
part 2
The Scaling
 
 
                function OnGUI()
 {
     if(GUI.Button(ResizeGUI(Rect(470, 225, 100, 50)), "Settings"))
     {
         
     }
 }
 
 function ResizeGUI(_rect : Rect) : Rect
 {
     var FilScreenWidth = _rect.width / 800;
     var rectWidth = FilScreenWidth * Screen.width;
     var FilScreenHeight = _rect.height / 600;
     var rectHeight = FilScreenHeight * Screen.height;
     var rectX = (_rect.x / 800) * Screen.width;
     var rectY = (_rect.y / 600) * Screen.height;
  
     return Rect(rectX,rectY,rectWidth,rectHeight);
 }
  
                
This is my entire script if you need it 
 
                #pragma strict
 
 var BG : Texture2D;
 var skin3 : GUISkin;
 var Hover : GUIStyleState;
 var shadow : Texture2D;
 static var inGame = false;
 private var rotAngle : float = 90;
 private var pivotPoint : Vector2;
 
 function OnGUI () 
 {
     GUI.skin = skin3;
     GUI.DrawTexture(ResizeGUI(Rect(0, 0, 800, 600)), BG);
     GUI.DrawTexture(ResizeGUI(Rect(50, 0, 700, 350)), shadow);
     GUI.skin.button.onHover.textColor = Color.cyan;
     if(GUI.Button(ResizeGUI(Rect(310, 380, 55, 35)), "Play"))
     {
         Application.LoadLevel(1);
         inGame = true;
     }
     if(GUI.Button(ResizeGUI(Rect(635, 20, 40, 30)), "Exit"))
     {
         Application.Quit();
     }
     
     pivotPoint = Vector2(Screen.width/2,Screen.height/2);
     GUIUtility.RotateAroundPivot (rotAngle, pivotPoint); 
     if(GUI.Button(ResizeGUI(Rect(470, 225, 100, 50)), "Settings"))
     {
         
     }
     
     if(GUI.Button(ResizeGUI(Rect(470, 100, 100,50)), "Credits"))
     {
         
     }
 }
 
 function Update () {
 
 }
 
 function ResizeGUI(_rect : Rect) : Rect
 {
     var FilScreenWidth = _rect.width / 800;
     var rectWidth = FilScreenWidth * Screen.width;
     var FilScreenHeight = _rect.height / 600;
     var rectHeight = FilScreenHeight * Screen.height;
     var rectX = (_rect.x / 800) * Screen.width;
     var rectY = (_rect.y / 600) * Screen.height;
  
     return Rect(rectX,rectY,rectWidth,rectHeight);
 }
  
                
thanks in advance skullbeats1
(sorry for the confusion)
               Comment
              
 
               
              Your answer