0

I am having an issue regarding unity scene loading from assetbundle. I have created a scene with vuforia ARCamera and few image targets. I converted that to an assetbundle. Till now is fine but when I'm importing and loading the scene, it is showing a black scene without showing the AR camera but the image target is detecting the marker and showing the result on the black screen. Is there any way to start the AR camera after loading the assetbundle scene?

Thanks in advance.

gowthy
  • 3
  • 2
  • 5

1 Answers1

0

Is there any way to start the AR camera after loading the assetbundle scene?

you can wait for a scene to load using SceneManager.sceneLoaded. Then when the scene is completely loaded you can instantiate/activate your AR camera.

// called first
void OnEnable()
{
    SceneManager.sceneLoaded += OnSceneLoaded;
}

// called second
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
    //Put the code to enable/instantiate your ARCamera here
}

do mind that this has to be called after you have completely loaded the assetbundle

More info on how the SceneManager works can be found in the SceneManager unity docs

Remy
  • 4,843
  • 5
  • 30
  • 60
  • did it work? if so please accept the answer so other can also find it. if not we can try to help more – Remy Jul 26 '18 at 12:24
  • No, it was not working...basically I tried another method by creating an empty scene and adding AR Camera and a gameobject with a script to load the assetbundle scene and wrote the code that does not destroy the AR Camera when switching to assetbundle scene. Now the camera is running but when i keep any marker then it is going to black screen after recognizing the marker. – gowthy Jul 26 '18 at 13:13
  • Simple Asset bundle download starts in loading scene than loading your remain scene, but still can't get your problem, in which way asset bundle effect on your AR camera ??? **Give Your actual problem, so, I can give you a way to solve that problem. – Hardik Jul 30 '18 at 13:54
  • Vuforia Start as soon as application start, so it's better to change your logic, and just send Your 3d object and other property in Asset bundle, and instantiate object runtime, if you using asset bundle for Size reduce. or let me know the reason so I can give an alternate way to do. – Hardik Jul 30 '18 at 14:01
  • thanks for your reply Hardik, I have few tasks in my project as individual scenes. I kept buttons for each task(scene) in my main scene. So, if anyone clicks on a button then that particular task scene should be downloaded and open at runtime. Here i created each scene as separate assetbundle. I have AR Camera in the scene but when I download and open a particular bundle(scene) everything is loading but AR Camera is showing as black screen and when I keep any image target marker in front of camera, I'm able to see the content that relates to marker on the black screen. – gowthy Jul 31 '18 at 12:51
  • the only problem here is that AR Camera is not starting after scene(assetbundle) loads, rest of the content in the scene is working fine. – gowthy Jul 31 '18 at 12:53