Showing posts from June, 2022

Create Asset bundle in Unity3d

 Original Source: Create Asset Bundle in unity3d – step by step guide Step 1 Select the asset that you want to add in asset bundle. In the bottom of Inspector pane, click on asset bundle field. Step 2 Click on the  new  if you want to add your asset in new asset bundle or select the already named asset bundle. You will get the entire named asset bundle over here. You can add multiple assets to a single asset bundle name. Step 3 Write the name of the asset bundle and hit ENTER key. Then you will see name of your asset bundle in the  AssetBundle  field. Step 4 Add  Editor  Folder in Assets folder and add below script in this folder.  Asset bundles are platform (android, iOS etc) dependent; so generate asset bundle accordingly. You can select platform by setting  BuildTarget  argument.  For below code, assets bundles will be generated in “Assets/AssetBundles” folder. 1 2 3 4 5 6 7 8 9 10 using UnityEditor ;   public clas

How to Load Asset Bundle in unity3d

Original Source: You can load asset bundle either locally or from an URL. First download the asset bundle using WWW class then you can load objects from the bundle. You can download asset bundle using WWW class. Non-caching:  Use object of WWW class to download data and it will be not cached in local storage of the device. 1 2 3 4 5 6 7 8 9 10 11 12 13 void Start ( ) { string url = "your url" ; StartCoroutine ( loadWWWNonCaching ( url ) ) ; } IEnumerator loadWWWNonCaching ( string url ) { WWW www = new WWW ( url ) ; yield return www ; if ( string . IsNullOrEmpty ( www . error ) ) { AssetBundle assetBundle = www . assetBundle ; } else { Debug . Log ( "WWW error: " + www . error ) ; } } Caching:  WWW. LoadFromCacheOrDownload  method allows you to load asset bundle either from cache memory or by downloading it. If cache will be clean then it wil