- Home /
This question was
closed Apr 15, 2016 at 07:01 PM by
CodewithFin for the following reason:
The question is answered, right answer was accepted
Question by
CodewithFin · Apr 15, 2016 at 06:37 PM ·
c#onclick
Script working but still don't get OnClick option.
I have a working script with an OnClick function but when I access the function from the button it doesn't give me the option..?
void OnClick()
{
StartCoroutine(MyMethod());
}
IEnumerator MyMethod()
{
GetComponent<AudioSource>().Play();
yield return new WaitForSeconds(.5f);
SceneManager.LoadScene("MainMenu");
}
Comment
Best Answer
Answer by jgodfrey · Apr 15, 2016 at 06:41 PM
The OnClick() method has to be pulic. So, change...
void OnClick()
to
public void OnClick()