Question by
shanzebali · May 09, 2016 at 05:19 PM ·
buttonienumeratornotworking
Public IEnumerator wont work if attached to a button.
, public IEnumerator ResumeIfLives()
{
if (lives > livesRequired)
{
lives = lives - livesRequired;
yield return new WaitForSeconds(3);
Time.timeScale = 1.0f;
}
yield return null;
}
ERROR:
ArgumentException: method return type is incompatible
Comment
I get no such error from your snippet even when attached to a button.
I have posted the script below Please help if possible.
I have posted the script below Please help if possible.
IEnumerator ResumeIfLives()
{
if (lives > livesRequired)
{
lives = lives - livesRequired;
go.GetComponent<Player>().dead = false;
yield return new WaitForSeconds(5f);
Time.timeScale = 1.0f;
}
yield return null;
}
public void ResumeButton()
{
StopCoroutine(ResumeIfLives());
StartCoroutine(ResumeIfLives());
}
i tried making another public void function now it can be attached to a button. This is the script it brings the player back from dead but it does not change the time scale back to 1.0f. I don't know if i am doing it wrong; but i think it doesn't works after the waitForSeconds().