Search Unity

Question Loading a scene from asset bundle - Android

Discussion in 'Android' started by Trojanonator, Jul 7, 2021.

  1. Trojanonator

    Trojanonator

    Joined:
    Jul 20, 2018
    Posts:
    1
    Hi, I have a working AR app, using Vuforia that I can't upload to Play Store because it is larger than 150 MB.

    So the only solution is Asset Bundle. I created Bundle of my Main Scene and put the script for retrieving and loading in my Startup Scene. Delivery mode is set to Install Time. Building the app works fine, so does deployment to my Android device, but it opens just blank window. It doesn't even open Startup scene with SplashScreen.

    This is the script for loading the scene. It's attached to empty GameObject.


    Code (CSharp):
    1.  using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5. using Google.Play.AssetDelivery;
    6. public class LoadSceneFromAssetBundle : MonoBehaviour
    7. {
    8.      public void Start()
    9.      {
    10.          PlayAssetBundleRequest bundleRequest = PlayAssetDelivery.RetrieveAssetBundleAsync("scenebundle");
    11.          AssetBundle assetBundle = bundleRequest.AssetBundle;
    12.          string[] scenePaths = assetBundle.GetAllScenePaths();
    13.          SceneManager.LoadScene(scenePaths[0]);
    14.      }
    15. }
    16.  



    Thank you very much for help.