- Home /
GUI Variable Declaration problem
var OptionState : boolean = false;
var Option : Rect = new Rect(bwidth2,bheight2 + margin,bwidth,bheight); //holds actual button rect coordinates
var initialPosition : Rect = new Rect(bwidth2,bheight2 + margin,bwidth,bheight); //holds starting rect coordinates
var activePosition : Rect = new Rect(-bwidth,bheight2 + margin,bwidth,bheight); //holds ending rect coordinates
Option.width = bwidth2;
//==========================================
FPSCamera = transform.Find("Main Camera");
MainArrow = gameObject.Find("Guide");
function OnGUI(){
if(GUI.Button(Option,"Option!"))
{
if(OptionState){
iTween.ValueTo(gameObject,iTween.Hash("from",Option,"to",initialPosition,"onupdate","MoveButton","easetype","easeinoutback","ignoretimescale",true));
}else{
iTween.ValueTo(gameObject,iTween.Hash("from",Option,"to",activePosition,"onupdate","MoveButton","easetype","easeinoutback","ignoretimescale",true));
}
OptionState = !OptionState;
}
}
I want to auto Size and auto Place my Button to Center at the same time if I click it, it will animate. but the button always setting up to 0,0,0,0. Please Help me Good Guys.
Comment
Are you doing this in JS or C#? Because it looks to me like Javascript, but your iTween code is using the C# example.
Does your code work if you coment out the code within if(OptionState)?
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
My GUI IS Bugging Out. Can Anyone Help? 0 Answers
GUI.DrawTexture Error & Static Variables!! 2 Answers