- Home /
OnMouseDown how to call yield?
I want after few sec that my GameLog is erazed so it's not at screen all the time
if you think it's too simplified I'll post whole code
public class PickUpObject : MonoBehaviour {
private GameObject Player ;
public Depth0 Depth0Script;
void Start () {
Player = GameObject.Find("Camera");
Depth0Script = Player.GetComponent("Depth0") as Depth0;
}
void OnMouseDown () {
Depth0Script.GameLogs = ("humh I need tools for this");
Depth0Script.GameLogTimerF();
}
public class Depth0 : MonoBehaviour {
public string GameLogs = "" ;
private float GameLogTimerf = 1;
public IEnumerator GameLogTimerF (){
GameLogs = "";
yield return new WaitForSeconds(GameLogTimerf);
}
}
now If I just change 2 lines here it works but I want it to wait too
public Void GameLogTimerF (){
GameLogs = "";
//yield return new WaitForSeconds(GameLogTimerf);
}
what am I doing wrong why does it not want to call this function?
how do I call it?
Answer by StephanK · Jan 28, 2013 at 10:08 AM
StartCoroutine(Depth0Script.GameLogTimerF());
ok I called
StartCoroutine(Depth0Script.GameLogTimerF());
ins$$anonymous$$d of
Depth0Script.GameLogTimerF();
but it still doesn't work
ammmmm... and is this normal?
yesterday when I tried the way you showed me didn't work today that I've started my PC it worked I didn't even touch the code
I'm using Unity 4.1 iirc (free)
$$anonymous$$onoDevelop 2.8.2
Your answer
Follow this Question
Related Questions
Problem with dictionary inside of a class 0 Answers
OnMouseDown() cube face? 1 Answer
Turn on gravity on a single gameobject with OnMouseDown 1 Answer
OnMouseDown Boolean 2 Answers