- Home /
 
               Question by 
               FarisGames · Aug 22, 2013 at 03:21 PM · 
                guitextureitween  
              
 
              Scale a GUITexture from its center
Hello,
I tried scaling a GUITexture to do an animation with iTween but unfortunately it turned to hell for me. it scales from the bottom left of the GUITexture. is there any possible way to make it scale from the center ?
PS: JS User
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by robertbu · Aug 22, 2013 at 04:22 PM
If you are scaling your GUITexture by changing the Pixel Inset width and height, you can anchor at the center by setting x and y to negative 1/2 the width and height respectively every time you change the width and height.
maybe you can give me a rough idea with codes ? Thanks!
Attach this script to a GUITexture object. Run and hit the space bar:
 #pragma strict
 
 function Update() {
 
 if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Space))
     ResizeGUITex(400.0, 400.0);
 }
 
 function ResizeGUITex(newWidth : float, newHeight : float) {
     guiTexture.pixelInset.width = newWidth;
     guiTexture.pixelInset.height = newHeight;
     guiTexture.pixelInset.x = -newWidth / 2.0;
     guiTexture.pixelInset.y = -newWidth / 2.0;
 }
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                