Quantcast
Channel: Questions in topic: "xcode"
Viewing all articles
Browse latest Browse all 1047

On Demand Resource & Asset Bundle Manager? Unity 5.6.0 & Xcode 8.2

$
0
0
Hi, I am doing ODR using Asset Bundle Manager from bitbucket. I am making large prefab containing complete canvas hierarchy & it contains all the animations & sounds in it. When i initially tested it was working fine and showing 22 mb on test flight. Initially i was using uncompressedAssetBundle for building the assets. Then i started making more prefabs for all the mini games and some prefabs had reference/connection from resources folder and when i uploaded the build to testflight it was showing 224 mb. And yes when i started making more prefabs i changed the build option to chunkbasedAsset from uncompressedAssetBundle. it was showing correct in xcode in Resource Tags tab... like prefabs sized were 4 mb, 7 mb, 10 mb.. etc etc. I read somewhere if u put any resource in Resources Folder and load it from there it goes with the binary or executable. So then i removed all the references from those prefabs, basically i removed the asset tags from it. But to my surprise when i loaded it after that to the test flight it size increased to 280 mb. I am using the below script for loading the prefab for ODR and Asset Bundle Manager from bitbucket. PS: I am using scripting backend as IL2CPP and Architecture universal. using System.Collections; using System.Collections.Generic; using UnityEngine; using AssetBundles; public class LoadResources : MonoBehaviour { public const string AssetBundlesOutputPath = "/AssetBundles/"; public string assetBundleName; public string assetName; private List assetBundleNames = new List() { "firefighter_van" }; private List assetNames = new List() { "Van" }; AssetBundleLoadAssetOperation request; // Use this for initialization IEnumerator Start() { yield return StartCoroutine(Initialize()); // Load asset. yield return StartCoroutine(InstantiateGameObjectAsync(assetBundleName, assetName)); } // Initialize the downloading URL. // eg. Development server / iOS ODR / web URL void InitializeSourceURL() { // If ODR is available and enabled, then use it and let Xcode handle download requests. #if ENABLE_IOS_ON_DEMAND_RESOURCES if (UnityEngine.iOS.OnDemandResources.enabled) { Debug.Log("Inside Initialize source URL ODR Enabled"); AssetBundleManager.SetSourceAssetBundleURL("odr://"); return; } #endif #if DEVELOPMENT_BUILD || UNITY_EDITOR // With this code, when in-editor or using a development builds: Always use the AssetBundle Server // (This is very dependent on the production workflow of the project. // Another approach would be to make this configurable in the standalone player.) Debug.Log("Inside Initialize source URL Set Development Asset Bundle Server"); AssetBundleManager.SetDevelopmentAssetBundleServer(); return; #else Debug.Log("Inside Initialize source URL Application data path"); // Use the following code if AssetBundles are embedded in the project for example via StreamingAssets folder etc: AssetBundleManager.SetSourceAssetBundleURL(Application.dataPath + "/"); // Or customize the URL based on your deployment or configuration //AssetBundleManager.SetSourceAssetBundleURL("http://www.MyWebsite/MyAssetBundles"); // return; #endif } // Initialize the downloading url and AssetBundleManifest object. protected IEnumerator Initialize() { // Don't destroy this gameObject as we depend on it to run the loading script. DontDestroyOnLoad(gameObject); InitializeSourceURL(); // Initialize AssetBundleManifest which loads the AssetBundleManifest object. var request = AssetBundleManager.Initialize(); if (request != null) yield return StartCoroutine(request); } protected IEnumerator InstantiateGameObjectAsync(string assetBundleName, string assetName) { // This is simply to get the elapsed time for this phase of AssetLoading. float startTime = Time.realtimeSinceStartup; // Load asset from assetBundle. //AssetBundleLoadAssetOperation request = AssetBundleManager.LoadAssetAsync(assetBundleName, assetName, typeof(GameObject)); request = AssetBundleManager.LoadAssetAsync(assetBundleName, assetName, typeof(GameObject)); if (request == null) yield break; yield return StartCoroutine(request); // Get the asset. Debug.Log ("Request Successful"); Debug.Log(request.GetAsset().name); GameObject prefab = request.GetAsset(); if (prefab != null) { GameObject obj = GameObject.Instantiate (prefab); Debug.Log ("Downloaded Asset"); } // Calculate and display the elapsed time. float elapsedTime = Time.realtimeSinceStartup - startTime; Debug.Log(assetName + (prefab == null ? " was not" : " was") + " loaded successfully in " + elapsedTime + " seconds"); } }

Viewing all articles
Browse latest Browse all 1047

Trending Articles



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