I have 2 scripts attached to 2 different objects, when the first object becomes visible the second script whit my GUI is enabled, when the first object disappears, I want to close my GUI. The problem is that when the GUI is closed I can’t see the animations of the buttons in it because there’s no time to show them. This is my code, maybe it explains my problem better:
first script:
var otherScript : guifinal;
if (renderer.isVisible) {
otherScript.enabled = true;
}
else {
DisableRendererWithDelay();
}
}
function DisableRendererWithDelay() {
yield WaitForSeconds(2);
otherScript.enabled = false;
}
second script:
function OnEnable(){
iTween.ValueTo(gameObject,iTween.Hash("from",CurrentButtonSize(),"to",buttonVertSize,"easetype",iTween.EaseType.easeOutBack,"onupdate","ScaleButton","time",.5,"delay",.3));
iTween.ValueTo(gameObject,iTween.Hash("from",VertButtonSize(),"to",buttonOrizSize,"easetype",iTween.EaseType.easeOutBack,"onupdate","ScaleButton","time",.5,"delay",1));
}
function OnDisable(){
iTween.ValueTo(gameObject,iTween.Hash("from",CurrentButtonSize(),"to",buttonNormalSize,"easetype",iTween.EaseType.easeOutBack,"onupdate","ScaleButton","time",.5,"delay",.2));
}
There is a way to send instantly the trigger of “otherScript.enabled = true” but execute it after 2 seconds?