大家也知道,AssetBundle對於Script的不方便,一定要在Project內事先放入相同的Script,才能讓AssetBundle上的Script相對應到。
但這都不是重點,本篇的重點是將AssetBundle匯入到Unity程式內使用。
using UnityEngine;
using System.Collections;
public class AssetBundleLoadController : MonoBehaviour {
void Start ()
{
StartCoroutine( LoadAssetBundle() );
}
private IEnumerator LocalLoad()
{
WWW fileBundle = new WWW( "file://D:/xxx.assetbundle" );
yield return fileBundle;
GameObject tempObject = null;
yield return tempObject = Instantiate( fileBundle.assetBundle.mainAsset ) as GameObject;
tempObject.name = tempObject.name.Replace( "(Clone)", string.Empty );
fileBundle.assetBundle.Unload( false );
Resources.UnloadUnusedAssets();
}
}
這樣就能使用AssetBundle的內容物了。
沒有留言:
張貼留言