Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Asset Bundle loading scene issue

Discussion in 'Scripting' started by djoshi, Jun 8, 2017.

  1. djoshi

    djoshi

    Joined:
    Mar 28, 2014
    Posts:
    182
    Hi,
    I am trying to load scene from asset bundle & then loading that scene at runtime. After loading scene I'm unloading the asset bundle using bundle(false). Initially it works good but after one or more attempts its showing me error No Camera is rendering and all the gameObjects are destroyed. I think it unloads before the scene is loaded. Below is my code snippet that I've used:
    myLoadedAssetBundle = wwwAsset.assetBundle;
    string[] path = myLoadedAssetBundle.GetAllScenePaths ();
    SceneManager.LoadSceneAsync (path[0]);

    myLoadedAssetBundle.Unload (false);

    I can't even unload the asset bundle after loading scene as the scene gets changed & above script is destroyed .
    I would appreciate any work around for this issue.
    Thanks in adv.
     
  2. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    Since you're using SceneManager.LoadSceneAsync, are you waiting for that to finish first before unloading the asset bundle?
     
  3. djoshi

    djoshi

    Joined:
    Mar 28, 2014
    Posts:
    182
    Its bit problematic, I want to load a scene but also want it to unload it before switching to that scene. Or unload it from next scene but since the older scene does not exist, I cant unload it, that variable got destroyed.
     
  4. djoshi

    djoshi

    Joined:
    Mar 28, 2014
    Posts:
    182
    Well I found the issue.. Done using static variable. Thanks !! :)