Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class LoadGameObject : MonoBehaviour {
- public int version;
- AssetBundle bundle;
- public string url = "http://app.baib52.com/test/Cubes.unity3d";
- public string url_android = "http://app.baib52.com/test/Cubes.unity3d.android.unity3d";
- WWW www;
- // Use this for initialization
- void Start () {
- StartCoroutine(LoadData());
- }
- // Update is called once per frame
- void Update () {
- }
- IEnumerator LoadData()
- {
- www = WWW.LoadFromCacheOrDownload(url, version);
- // www = new WWW(url);
- yield return www;
- Debug.Log(string.Format("Progress - {0}%. from {1}", www.progress * 100, www.url));
- if (Application.platform == RuntimePlatform.Android)
- {
- www = WWW.LoadFromCacheOrDownload(url_android, version);
- // www = new WWW(url_android);
- yield return www;
- }
- //while (www.progress < 1)
- //{
- // m_CurrentValue = www.progress * 100;
- // Debug.Log(string.Format("Progress - {0}%. from {1}", www.progress * 100, www.url));
- // yield return new WaitForSeconds(.1f);
- //}
- bundle = www.assetBundle;
- GameObject obj = bundle.Load("Cubes", typeof(GameObject)) as GameObject;
- Instantiate(obj);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment