Question by
Daloo92 · Oct 17, 2016 at 04:50 AM ·
c#uiscene-loadingbuttonsscene-change
error CS1736: The expression being assigned to optional parameter `i' must be a constant or default value
Hello. I am trying to make a "next level" button, and I want it to take me to the next scene. I found this answer: http://answers.unity3d.com/questions/620750/load-next-level.html and they suggested that I add "int i". But in that question it was for an older version of unity. Anyway, here is a sample of my code:
public void NextLevel () {
int i = SceneManager.LoadScene;
SceneManager.LoadScene (i + 1);
}
where did i go wrong? (I'm really new to coding, so I don't know much. sorry if it's a silly question)
Comment
int i = Scene$$anonymous$$anager.GetActiveScene().buildIndex;
Scene$$anonymous$$anager.LoadScene (i + 1);
I would recommend you to learn c# language basics first.
Thank You!! It worked! And yeah I know that :P I am currently learning C# but I am too eager to try out a bunch of stuff in unity even though I still haven't learnt much :D