- Home /
Question by
C8H11N02 · Nov 18, 2019 at 10:52 AM ·
ienumeratorcall
How to call function parameter
I want call int leveint in ienumerator levelint
public void level(**int levelint**)
{
StartCoroutine(ChangeScene());
}
IEnumerator ChangeScene() {
yield return new WaitForSeconds(1);
SceneManager.LoadScene(**levelint**);
Time.timeScale = 1;
}
Comment
Answer by Ermiq · Nov 18, 2019 at 11:14 AM
public void level(int levelint) {
StartCoroutine(ChangeScene(levelint));
}
IEnumerator ChangeScene(int levelint) {
yield return new WaitForSeconds(1);
SceneManager.LoadScene(levelint);
Time.timeScale = 1;
}
or
int levelint;
public void level(int level) {
levelint = level;
StartCoroutine(ChangeScene());
}
IEnumerator ChangeScene() {
yield return new WaitForSeconds(1);
SceneManager.LoadScene(levelint);
Time.timeScale = 1;
}
It does work, probably you don't have your scene indexes set up correctly in the build menu.
Well, it can not not to work. It's very basic method of sending arguments to a function in C# (and any other similar language). As ShadyProductions said, you should check out your setup.
Your answer
![](https://koobas.hobune.stream/wayback/20220612214941im_/https://answers.unity.com/themes/thub/images/avi.jpg)