saifuddinazhar
3/30/2019 - 9:28 AM

Create And Load AssetBundle

AssetBundle assetBundle = AssetBundle.LoadFromFile(Config.ASSET_BUNDLE_PATH + "images.thumbnailacessories");
Texture2D texture2D = assetBundle.LoadAsset<Texture2D>("female clothes 1");
Sprite sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), new Vector2(0.5f, 0.5f));
GameObject.Find("Image Test").GetComponent<Image>().sprite = sprite;
AssetBundle assetBundle = AssetBundle.LoadFromFile(Config.ASSET_BUNDLE_PATH + "scenes.temp");
AssetBundle.LoadFromFile(Config.ASSET_BUNDLE_PATH + "AssetBundles");
AssetBundle.LoadFromFile(Config.ASSET_BUNDLE_PATH + "prefabs.temp");
AssetBundle.LoadFromFile(Config.ASSET_BUNDLE_PATH + "textures.temp");
AssetBundle.LoadFromFile(Config.ASSET_BUNDLE_PATH + "skyboxes.temp");

string[] scenePath = assetBundle.GetAllScenePaths();
SceneManager.LoadScene(scenePath[0]);
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;

public class AssetBundleCreator : MonoBehaviour {
    [MenuItem("Assets/Build Asset Bundle")]
    static void BuildBundle()
    {
        BuildPipeline.BuildAssetBundles(Config.ASSET_BUNDLE_PATH, BuildAssetBundleOptions.None, BuildTarget.Android);
    }
}
#endif