- Home /
Question by
lancer · Aug 22, 2013 at 09:29 PM ·
javascriptyieldongui
yield OnGUI
How can I use yield WaitForSeconds in OnGUI? I need it to show a certain set of images, wait for 2 seconds and display another set of images, etc. I'm using JavaScript.
Comment
Best Answer
Answer by YoungDeveloper · Aug 22, 2013 at 10:00 PM
Create new function which does the yields, after each do simple manipulations with booleans.
// create boolean for each image, like in this example each "showimage" is a bool.
function WaitFuntion(){
showimage1 = true;
yield.....
showimage1 = false;
showimage2 =true;
yield.....
showimage2 = false;
showimage3 = true;
//etc
}
//And in gui function create simple if statements
function OnGUI(){
if(showimage1 ==true) {//image 1 gui rect }
if(showimage2 ==true) {//image 2 gui rect }
if(showimage2 ==true) {//image 3 gui rect }
}
//Remember to set everything on false in the start function
Your answer
Follow this Question
Related Questions
Walking sound change 0 Answers
Wiggle Or shake button possible? 2 Answers
Problem with yield waitForSeconds in for loop 0 Answers
Confused about Coroutines 2 Answers
How can I make a variable false for a period of time? 3 Answers