Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C#

please explain sceneBuildIndex

To reset the scene, the line of code was: SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); I am not finding documentation to explain this other than it returns "-1". so why not do SceneManager.LoadScene(-1) ? What else is buildIndex doing and how else would you use it other than to get "-1"?

Steven Parker
Steven Parker
231,126 Points

To enable the most complete and accurate analysis, always include a link to the course page you were working with.

Also, are you sure this question is for the "C#" category and not "Game Development"? You can change categories in "Edit Question" if needed.

Seth Kroger
Seth Kroger
56,413 Points

A -1 is often returned to indicate an error or special condition, such as a "not found" condition. I'd suggest looking up the docs for whatever framework you're using because I'm almost certain it's not "always returns -1" but "returns -1 if..."