[code=javascript]var maxTime:float = 1;
private var dTime:float = 0;
public var tag1:GameObject;
function OnGUI(){
if(dTime==0){
if(GUI.Button (Rect(10,10,100,20), "HideOrNot")){
dTime = maxTime;
tag1.active=true;
}
}
if(dTime>0 && dTime<maxTime){
if(GUI.Button (Rect (10,10,100,20), "HideOrNot")){
dTime=0; tag1.active=false;
}
}
}
function Update () {
//~ ----------------------------------------
if(dTime>0 && dTime!=0)
dTime = dTime-Time.deltaTime*2;
if(dTime<0)
dTime =0;
//~ -----------------------------------------
}
[/code] |