|
- void OnGUI(){
-  
- if(GUI.Button(new Rect(5,35,100,25) , "Load GameObject")){
-  
- StartCoroutine(LoadGameObject());
- }
- }
-  
- private IEnumerator LoadGameObject(){
-  
- // AssetBundle 檔案路徑
- string path = string.Format("file://{0}/../_AssetBunldes/{1}.assetBunldes" , Application.dataPath , "TestGameObject");
-  
- // 載入 AssetBundle
- WWW bundle = new WWW(path);
-  
- //等待載入完成
- yield return bundle;
-  
- //實例化 GameObject 並等待實作完成
- yield return Instantiate(bundle.assetBundle.mainAsset);
-  
- //卸載 AssetBundle
- bundle.assetBundle.Unload(false);
- }
复制代码 |
|