Hi,
I put down an empty gameobject and attached a script. With the script I added an image:
function OnGUI () {
GUI.DrawTexture(new Rect(25,200,30,1), fearBG);
}
Now I would like to change the height of this image through a function. How can I change the height in javascript?
I read it was possible by changing the pixel inset. However if I do the following, it won’t work?
function testF() {
guiTexture.pixelInset.y = 50;
}
Eric5h5
September 3, 2012, 2:50am
2
GUITextures have nothing to do with OnGUI code, so ignore all that. If you want to change the rect size, just, well, change the rect size. You have a rect there in OnGUI, so you can change the numbers as appropriate. The height that you have is 30, so change that to something else.
Try this for showing what Eric5h5 means about GUITextures have nothing to do with OnGUI
var wasClicked = “”;
function OnGUI(){
if(wasClicked == ""){
GUI.DrawTexture(new Rect(25,200,30,1), fearBG);
if(GUI.Button(new Rect((Screen.width/2)-100,(Screen.height/2)+50,200,30),"Options"))
{
testF();
}
}else if(wasClicked == "clicked")
GUI.DrawTexture(new Rect(25,200,30,50), fearBG);
}
function testF(){
wasClicked = "clicked";
}