Forum rules - please read before posting.

Error on scenechanger.ChangeScene

I've got a Map canvas UI, with a button that passes a string with a scene to load. I'm then using AC.KickStarter.sceneChanger.ChangeScene(name, true);

Confirmed the string isn't null and the Scene exists, but getting an error when it comes to the actual load?

Cannot load scene: Invalid scene name (empty string) and invalid build index -1 UnityEngine.SceneManagement.SceneManager:LoadSceneAsync (int,UnityEngine.SceneManagement.LoadSceneMode) AC.SceneInfo:OpenAsync (UnityEngine.SceneManagement.LoadSceneMode) (at Assets/AdventureCreator/Scripts/Game engine/SceneInfo.cs:157) AC.SceneChanger/d__50:MoveNext () (at Assets/AdventureCreator/Scripts/Game engine/SceneChanger.cs:969) UnityEngine.MonoBehaviour:StartCoroutine (System.Collections.IEnumerator) AC.SceneChanger:LoadLevelAsync (string,bool) (at Assets/AdventureCreator/Scripts/Game engine/SceneChanger.cs:862) AC.SceneChanger:LoadLevel (string,bool,bool,bool,bool) (at Assets/AdventureCreator/Scripts/Game engine/SceneChanger.cs:596) AC.SceneChanger:ChangeScene (string,bool,bool,bool) (at Assets/AdventureCreator/Scripts/Game engine/SceneChanger.cs:304) Map:OnClick (string) (at Assets/Code/UI/Map/Map.cs:33)

It makes it through the Scenechanger error checks, which makes me wonder if this might not be my end? It almost definitely is my end, but thought I'd flag it anyway while I investigate :/

Comments

  • Looks like it could be down to the Reference scenes by field in the Settings Manager's Saving panel - is this set to Name or Number?

    When using the Scene: Switch Action, this shouldn't matter - as it'll convert a string to a build index, and vice-versa.

    Otherwise, if you want to rely on Number, you'd need to pass in the build index instead of the name. You can do the conversion using the NameToIndex function:

    int buildIndex = KickStarter.sceneChange.NameToIndex ("MyScene");
    
  • Ah okay. Yeah, it's set to Number. Thanks!

    Wound up writing around it and passing the scene name as a parameter to an ActionListAsset, I'll probably leave it like that tbh since it comes with the benefit of being able to play dialogue/ fades etc as well.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.