- Home /
Load scene in Google VR on iOS
I'm trying to change scenes using Google Cardboard on an iPhone. I'm using
SceneManager.LoadScene("Scene2");
In the start() function of the FPS Controller. And have
using UnityEngine.SceneManagement;
At the top.
It works find in Unity, but when I build it on my phone, it crashes when it should load the new scene.
I am experiencing the same exact problem and have submitted a bug report. Hopefully this gets fixed soon, or a solution is found.
Answer by CardboardDude · May 25, 2017 at 02:57 PM
I submitted a bug report and was told that they fixed the problem and that it "should not appear in the upcoming 2017.1 version of Unity." I guess iOS cardboard devs will just have to wait until then.
Happy Coding,
Thanks! I have the same issue too, but I really need to switch between scenes for my project to work (it's for uni). Are there any alternatives or ways to workaround it? I just need to switch between scenes.
I tried "LoadScene" but that doesn't work either.
After some playing around it seems that loading a scene additively works fine. So the trick would be to load a scene additively and then unload the other (original) scene.
Scene$$anonymous$$anager.LoadScene ("SecondScene", LoadScene$$anonymous$$ode.Additive);
Then subscribe to the load scene event:
Scene$$anonymous$$anager.sceneLoaded += $$anonymous$$yScript.removeScene;
https://docs.unity3d.com/ScriptReference/Scene$$anonymous$$anagement.Scene$$anonymous$$anager-sceneLoaded.html http://answers.unity3d.com/questions/1322605/how-to-use-scenemanagersceneloaded-replacing-onlev.html
Inside the removeScene function unload the original scene:
Scene$$anonymous$$anager.UnloadSceneAsync ("FirstScene");
So Something like this:
public static void LoadScene(string name){
Scene$$anonymous$$anager.LoadScene (name, LoadScene$$anonymous$$ode.Additive);
Scene$$anonymous$$anager.sceneLoaded += $$anonymous$$yScript.killScene;
}
public static void killScene(Scene scene, LoadScene$$anonymous$$ode scene$$anonymous$$ode){
//Scene$$anonymous$$anager.UnloadSceneAsync ("SecondScene");
for(int i=0; i<Scene$$anonymous$$anager.sceneCount; i++){
if(!Scene$$anonymous$$anager.GetSceneAt(i).name.equals(scene.name)){
Scene$$anonymous$$anager.UnloadSceneAsync(Scene$$anonymous$$anager.GetSceneAt(i));
break;
}
}
}
The above functions are untested, but should give the general idea.
Happy coding and good luck.
If the approach outlined above does not work, you could also upgrade to the unity 2017.1 beta version of unity. This fixed the problem for me, however, BAC$$anonymous$$ UP YOUR PROJECT BEFORE YOU UPGRAD$$anonymous$$ Also, don't forget to downloaded the latest version of the google vr sdk.
Answer by lanalana · Jun 19, 2017 at 04:36 PM
Thank you, @CardboardDude! It worked with the 2017 beta. After trying 1.6 million things, that's all it took. >_< Thanks everyone for the responses!
Your answer
![](https://koobas.hobune.stream/wayback/20220612121550im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Display Activity indicator center 0 Answers
Push Notification to start a scene 2 Answers
iPhone Virtual Reality App won't load onto my phone. 0 Answers
Unity modules for iOS? 1 Answer