Quantcast
Channel: Questions in topic: "ios"
Viewing all articles
Browse latest Browse all 4709

Noob question about AssetBundle (iOS)

$
0
0
Hello, I'm a beginner in Unity dev for a iOS augmented reality app. Here's the context: the app has a dropdown menu to give users access to various levels based on scenes in the build. Currently, I have serialized an asset with 2 arrays: 1 for all scenes names in the build (scenesName) and 1 for the ones enabled in the build (scenesEnabled). So I can add them as dropdown menu options if they're enabled. It works fine inside Unity, I can populate the dropdown menu with the scenes checked in the build window. Of course, once on iOS, it needs to be in an assetbundle. So I used the "AssetBundles Browser" from Unity to create it. On my iPhone, it seems I can access to the asset inside the bundle through my code, but I don't know how to load objects inside the asset to be able to use them. I mean the problem is "how to access object inside bundle, not use the object itself" So, if someone would help me, it would be very nice ! Here's my code: using UnityEngine; using TMPro; using UnityEngine.SceneManagement; using System.Text.RegularExpressions; public class RetrieveBuiltScenes : MonoBehaviour { private string sceneName; TMP_Dropdown DropDownHome; // Name of my assetbundle string nameOfAssetBundle = "buildscenesassetbundle"; // Name of my asset string nameOfObjectToLoad = "ScenesList"; private void Start() { // Dropdown menu definition and Regex to keep only needed string from scenes name DropDownHome = GetComponent(); DropDownHome.ClearOptions(); Regex regex = new Regex(@"([^/]*/)*([\w\d\-]*)\.unity"); // Loading my assetbundle var myLoadedAssetBundle = AssetBundle.LoadFromFileAsync(Application.dataPath +"/Raw/" + nameOfAssetBundle); if (myLoadedAssetBundle.assetBundle == null) { Debug.Log("Failed to load AssetBundle!"); return; } else { // Loading my asset var assetLoadRequest = myLoadedAssetBundle.assetBundle.LoadAssetAsync(nameOfObjectToLoad); Debug.Log("AssetLoadRequest : " + assetLoadRequest); // I don't know what to do here ! myLoadedAssetBundle.assetBundle.Unload(false); }}

Viewing all articles
Browse latest Browse all 4709

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>