Instantiating mock environment from code

Hey!
I am converting our app from AR Foundation to Lightship ARDK. Is it possible to instantiate mock environment from code? In our app, we have 2 scenes. The first one is basically a profile menu, then you can go to the second scene, which starts the AR Session. If the Virtual Studio is open, the mock prefab gets placed in the first scene, where I don’t need it and it doesn’t get placed in the second scene, where it should be. Is there any way to solve this?

Hi Adam,

Thank you for your patience. This took a little bit of research.

So you can accomplish this by going to the MockSceneConfigurtion script on the Mock Environment and do the following:

Add an Awake() function where you add the GameObject (this.gameObject) to DoNotDestroyOnLoad, and then disable it. Afterwards, in that same Awake function, subscribe to the ARDK SessionInitialized event

On that callback function you create for the event, add a line to enable the GameObject.

This will ensure that on the first scene, which is just a menu, the Mock Environment will not render but will also not be destroyed and when you switch scenes, the event you subscribed to will listen to when an AR session starts and when it does it will be called and enable the Mock Environment.