SceneManager.GetActiveScene "takes only '1' argument" problem
Hey, I was using, before 5.3, this bit of code without any problem:
if (Application.loadedLevel == 1)
Now with 5.3 I have to use SceneManager but it doesn't work:
if (SceneManager.GetActiveScene (1))
Debug warning says: "No overload for method GetActiveScene takes '1' arguments". Could you please explain what is wrong? Thank you.
Answer by andrew-lukasik · Jan 24, 2016 at 06:20 PM
if( SceneManager.GetActiveScene().buildIndex==1 ) {
}
I noticed that Scene$$anonymous$$anager.GetActiveScene(); returns null between loading of scenes, so the .buildIndex logic worked for me. Thanks.
void OnCollisionEnter() { Player$$anonymous$$anager.health = 100; Destroy (this.gameObject); Debug.Log ("Active scene is " + scene.name); if (Scene$$anonymous$$anager.GetActiveScene().buildIndex==0) { Scene$$anonymous$$anager.LoadScene (1); } else if (Scene$$anonymous$$anager.GetActiveScene().buildIndex==1) { Scene$$anonymous$$anager.LoadScene (0); //0 to start over or use buildIndex of Next Scene to load }
}