Issue category: ARDK General
Device type & OS version: Android
Issue Environment : On Device
ARDK version: 1.0.1
Unity version: 2020.3.22f1
Description of the issue:
I have a MainMenuScene and a GameScene that I switch back inside my game. After a game ends I redirect player to the MainMenu to let them start another game. However when I load the GameScene again and initialize another session, it doesn’t detect previously detected planes. I feel like I need to do a cleanup before changing my scene. What is the correct way of cleaning up a session?
Hi Can, I’m not too sure what you meant by what you are asking. If you are loading another new GameScene and it doesn’t have the previously stored planes, what are the reasons that you would want to clean up the scene? Are you asking if there is a function that cleans up the scene instead of changing the game scene manually?
Let me try to clarify myself, after I detect planes and play the game in my Scene for gameplay, I open up the main menu again by loading my Scene for main menu. Then I press Play button again to load my gameplay Scene once again. When it’s the second time that I load the gameplay Scene, it somehow doesn’t detect planes correctly anymore.
I’m creating a new session so my expectation is detecting the planes all over again. But it feels like it doesn’t detect the planes that were already detected on previous session (I’m not sure if this is the actual way or not, this is how I feel). For example, I play the game for the first time. I scan on top of my bed. Finish the game, return back to the main menu. Then I play again. I try to scan/detect on top of my bed again but it doesn’t. However if I try to detect some other planes like the ground I can see the plane prefab is being created.
Let me know if it’s still not clear, maybe I can provide a video about it
Hi Layso. It might be the case that you are subscribing to some (ARDK/other) event in another script, and you are not unsubscribing when switching the scene. That might be causing null reference errors or memory leak, preventing the scene to work properly when reloading. Take a look here: Niantic AR Development Kit (ARDK): Subscribing to ARDK Events
This is an example of how I clean up before reloading a scene with ARDK objects. I am not an experienced coder, so perhaps I am not using the best practices here, but you’ll get the idea:
Hi Layso, just wanted to check in with you to see if you still need help on this issue? Did the above reply help?
Hi Layso, since this thread is not active, please open a new topic if this issue is still unresolved for you.