using UnityEngine; using System.Collections; public class LoadLogoAsset : MonoBehaviour { public string _prefabName; public int _BundleIndex=0; //public string _nextScenesName; //public string _previousScenesName; public int _nextSceneIndex; public int _previousSceneIndex; public bool _isReload; public GameObject _loadTexture; WWW _www; GameObject _insObjA; //------------------ static AssetBundle _BunA; static AssetBundle _BunB; static AssetBundle _BunC; static AssetBundle _BunD; static AssetBundle _BunE; static AssetBundle _BunF; //------------------ static AssetBundle[] _LogoBundle={_BunA,_BunB,_BunC,_BunD,_BunE}; IEnumerator Start() { Debug.Log(_LogoBundle[_BundleIndex]); if(_LogoBundle[_BundleIndex]==null){ if(Application.platform == RuntimePlatform.Android) { _www = new WWW(Application.streamingAssetsPath+"/"+_prefabName+".unity3d"); } else { _www = new WWW("file://" +Application.dataPath + "/StreamingAssets" + "/"+_prefabName+".unity3d"); } yield return _www; _LogoBundle[_BundleIndex]=_www.assetBundle; if(_www.progress==1){ OnIns(); } }else{ OnIns(); } } void OnGUI(){ GUI.color = Color.red; if(_LogoBundle[_BundleIndex]==null)GUI.Label(new Rect(10,10,500,100),(" "+(int)(_www.progress*100))); } public void OnIns(){ _loadTexture.SetActive(false); _insObjA=Instantiate(_LogoBundle[_BundleIndex].mainAsset)as GameObject;; } public void LoadNextScene(){ Destroy(_insObjA); if(_isReload){ _LogoBundle[_BundleIndex].Unload(false); } Application.LoadLevel(_nextSceneIndex); } public void LoadPreviousScene(){ Destroy(_insObjA); if(_isReload){ _LogoBundle[_BundleIndex].Unload(false); } Application.LoadLevel(_previousSceneIndex); } }