- Home /
Question by
xampozz · May 26, 2013 at 09:27 PM ·
javascriptjavaguilayoutgui layout
How do I resize the image on a GUILayout?
I need help to resize the image on my GUILayout so the images are placed add middle of the screen please help me :)
var ResumeGui : GUIStyle;
var RestartGui : GUIStyle;
var MainMenuGui : GUIStyle;
var Player : Transform;
private var GuiEnabled = false;
function Start(){
Time.timeScale=1;
GuiEnabled = false;
}
function Update(){
if(Input.GetKeyUp("escape")){
if(GuiEnabled==true){
GuiEnabled = false;
Time.timeScale=1;
AudioListener.volume=1;
Screen.showCursor=false;
}
else if(GuiEnabled == false){
GuiEnabled = true;
Time.timeScale=0;
AudioListener.volume=0;
Screen.showCursor=true;
}
}
}
function OnGUI(){
if(GuiEnabled==true){
if(GUILayout.Button (".", ResumeGui)){
Time.timeScale=1;
AudioListener.volume=1;
Screen.showCursor=false;
GuiEnabled = false;
}
}
if(GuiEnabled==true){
if (GUILayout.Button (".", MainMenuGui)){
Time.timeScale=1;
AudioListener.volume=1;
GuiEnabled=false;
Application.LoadLevel(0);
}
}
if(GuiEnabled==true){
if (GUILayout.Button (".", RestartGui)){
Time.timeScale=1;
AudioListener.volume=1;
GuiEnabled=false;
Player.position.x = 320.8074;
Player.position.y = 20.97857;
Player.position.z = 70.35075;
Player.rotation.x = 0;
Player.rotation.y = 0;
Player.rotation.z = 0;
Player.rigidbody.velocity = Vector3.zero;
Player.rigidbody.angularVelocity = Vector3.zero;
}
}
}
Comment
Best Answer
Answer by Kirbyrawr · May 26, 2013 at 09:37 PM
Okey:
GUI Style: If you are using this, you need to resize the image manually and for the aligment see the style editor in inspector window.
GUI.DrawTexture(Rect(Position of x, Position of y, Width, Height),name of the texture);
Hope it helps ^^
Happy to hear it, click on the tick for close this answer ^^ Good Deving!