I’m trying to make a shrinking GUI.Box/button
my problem is my GUI.Box doesn’t shrink/scale to it’s center… instead it shrink to its top left corner.
any idea how to align a GUIBox so it’ll scale/shrink in it’s center??
what I meant by center is not center of the screen,
the GUI position fixed with a gameObject,
I’m confused to explain this myself, so I’ll explain with a picture:
btw, thanks in advance
'n here’s the script:
#pragma strict
var ButtonScale = 0.0;
var Skin : GUISkin;
var failSkin : GUISkin;
var levelManager : LevelManager;
var IsActive=true;
var Counter=0;
var fail=false;
function Awake () {
}
function OnGUI () {
if (fail==false)
{GUI.skin = Skin;}
else
if (fail==true)
{GUI.skin = failSkin;}
var screenPos = Camera.main.WorldToScreenPoint (transform.position);
if (IsActive==true)
{GUI.Box(Rect (screenPos.x,Screen.height-Camera.main.WorldToScreenPoint (renderer.bounds.max).y,250-ButtonScale,250-ButtonScale), " ");
if (GUI.Button (Rect (screenPos.x,Screen.height-Camera.main.WorldToScreenPoint (renderer.bounds.max).y,250,250), " "))
{
if (fail==false){
IsActive=false;
Counter=0;
}
}
}
}
function Update () {
var cSpeed=levelManager.counterSpeed;
var sSpeed=levelManager.ButtonScaleSpeed;
if (IsActive==true){
ButtonScale += (Time.deltaTime * sSpeed);
Counter += cSpeed;
}
if (Counter >=70)
{
fail=true;
levelManager.fail();}
}