Advertisement
Bagserk

Load Asset Bundle in Unity

Aug 9th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.IO;
  4.  
  5. public class LoadFromFileExample : MonoBehaviour {
  6.  
  7.     // Use this for initialization
  8.     void Start () {
  9.         var myLoadedAssetBundle = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath , "assetbundle.unity3d"));
  10.         if (myLoadedAssetBundle == null)
  11.         {
  12.             Debug.Log("Failed to load AssetBundle!");
  13.             return;
  14.         }
  15.         var prefab = myLoadedAssetBundle.LoadAsset< GameObject > ("prefab name");
  16.         Instantiate(prefab);
  17.     }
  18.    
  19.     // Update is called once per frame
  20.     void Update () {
  21.    
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement