Gui Button zoom

Hi all,

var myTexture: Texture;
function OnGUI() {
if (GUI.Button(Rect(10,10,50,50),myTexture))
Debug.Log(“Clicked the button with an image”);

}

This is my button anyone know how i make the zoom effect button when the mouse is over this button?

Thanks in advance for Help

1 Answer

1

I think this will scale button :

var myTexture: Texture;

var myRect : Rect;

private var x = 10;

private var y = 10;

private var width = 50;

private var height = 50;

var sizeToGrowX = 10;

var sizeToGrowY = 10;

function Start ()

{

myRect =Rect(x,y,width,height);

}

function OnGUI()

{

if (GUI.Button(myRect,myTexture)) Debug.Log("Clicked the button with an image");

}

function Update ()

{

if(Input.mousePosition.x > x && Input.mousePosition.x < x+width)

{

	if(Input.mousePosition.y > y && Input.mousePosition.y < y-height)

	{

		x-sizeToGrowX;

		y-sizeToGrowY;

		width+(sizeToGrowX*2);

		height+(sizeToGrowY*2);

	}

}

else if(Input.mousePosition.x < x && Input.mousePosition.x > x+width)

{

	if(Input.mousePosition.y < y && Input.mousePosition.y > y-height)

	{

		x-sizeToGrowX;

		y-sizeToGrowY;

		width+(sizeToGrowX*2);

		height+(sizeToGrowY*2);

	}

}

}

can you format it, tht would be better for someone to understand?!

Thi can scale the button but the texture inside ?

<p>add this code to function Update if you want to scale texture as the button : <p>myTexture.width = width; myTexture.height = height; <p>or this if want to texture would be smaller : <p>//variables outside function Update !!! var minusScaleTexX = 2; var minusScaleTexY = 2; <p>//this inside function Update !!! myTexture.width = width - minusScaleTexX; myTexture.height = height - minusScaleTexY;