Exemplo n.º 1
0
    private IEnumerator loadTexture2DFromWWW(string url, Action <object> onloaded, Action <object> progressEvent, bool existAssetCache = false)
    {
        string path = url;

        if (existAssetCache)
        {
            path = BumDefine.bumThumbnailPathFile + BumDefine.getFileByUrl(url) + "/texture";
        }
        WWW www = new WWW(path);

        while (!www.isDone)
        {
            if (progressEvent != null)
            {
                progressEvent(www.progress);
            }
            yield return(null);
        }

        do
        {
            if (!string.IsNullOrEmpty(www.error))
            {
                BumBase.Log(www.error);
                break;
            }

            Texture2D texture = www.texture;
            if (texture != null)
            {
                //texture = bundle.LoadAsset<Texture2D>("texture");
                if (!existAssetCache)
                {
                    createCache(url, texture, BumResourceType.eBumResourceType_texture2D);
                }
                //bundle.Unload(false);
            }
            else
            {
                texture = www.texture;

                pool.addData(path, texture, BumResourceType.eBumResourceType_texture2D);

                if (!existAssetCache)
                {
                    createCache(url, texture, BumResourceType.eBumResourceType_texture2D);
                }
            }

            onloaded(texture);
        } while (false);

        www.Dispose();
        www = null;
    }
Exemplo n.º 2
0
    private IEnumerator loadJsonFromWWW(string url, Action <object> onloaded, Action <object> progressEvent, bool existAssetCache = false)
    {
        string path = url;

        if (existAssetCache)
        {
            path = BumDefine.bumDataConfigPathFile + BumDefine.getJsonFileByUrl(url);
        }

        WWW www = new WWW(url);

        while (!www.isDone)
        {
            if (progressEvent != null)
            {
                progressEvent(www.progress);
            }
            //yield return www;
        }

        do
        {
            if (!string.IsNullOrEmpty(www.error))
            {
                BumBase.Log(www.error);
                break;
            }
            string json  = System.Text.Encoding.UTF8.GetString(www.bytes);
            int    index = json.IndexOf("[");
            if (index > 0 && index < 2)
            {
                json = json.Substring(index);
            }
            if (!existAssetCache)
            {
                createCache(url, json, BumResourceType.eBumResourceType_json);
            }
            Debug.Log(json);
            onloaded(json);
        } while (false);
        www.Dispose();
        www = null;
        yield return(null);
    }
Exemplo n.º 3
0
    public void Startup()
    {
        System.TimeSpan ts = System.DateTime.Now - BumApp.Instance.clientInitTime;
        BumBase.Log("====================================Init Total Use {0}s===========================================", ts.TotalSeconds);

        //do...
        //if (string.IsNullOrEmpty(BumLogic.clientUser.userLocalRecord.userPhone))
        //{

        //    BumRep.uiManager.openWindow<BumUILoginPage>(0);
        //}
        //else
        //{
        //    BumRep.uiManager.openWindow<BumUIMainPage>();
        //    BumRep.uiManager.openWindow<BumUIBottomTools>();
        //}
        //BumRep.uiManager.openWindow<BumUIMainPage>();
        //BumRep.uiManager.openWindow<BumUIBottomTools>();
        //UIManager.Instance.OnOpen(PageType.MainPage);
    }
Exemplo n.º 4
0
    void Awake()
    {
        BumBase.Log("====================================================================================");
        BumBase.Log("Application.platform = {0}", Application.platform);
        BumBase.Log("Application.dataPath = {0}", Application.dataPath);
        BumBase.Log("Application.streamingAssetsPath = {0}", Application.streamingAssetsPath);
        BumBase.Log("Application.persistentDataPath = {0}", Application.persistentDataPath);
        BumBase.Log("Application.temporaryCachePath = {0}", Application.temporaryCachePath);
        BumBase.Log("Application.unityVersion = {0}", Application.unityVersion);
        BumBase.Log("SystemInfo.deviceModel = {0}", SystemInfo.deviceModel);
        BumBase.Log("====================================================================================");

        Instance = this;

        appLogic = new BumLogic();
        appRep   = new BumRep();

        setDivce();
        DontDestroyOnLoad(this);
    }
Exemplo n.º 5
0
    private IEnumerator loadUserInfoJsonFromWWW(string url, Action <object> onloaded, Action <object> progressEvent, bool existAssetCache = false)
    {
        string path = url;

        if (existAssetCache)
        {
            path = BumDefine.bumUserConfigPathFile + BumDefine.getJsonFileByUrl(url);
        }
        WWW www = new WWW(path);

        while (!www.isDone)
        {
            if (progressEvent != null)
            {
                progressEvent(www.progress);
            }
            yield return(null);
        }

        do
        {
            if (!string.IsNullOrEmpty(www.error))
            {
                BumBase.Log(www.error);
                break;
            }
            string json = System.Text.Encoding.UTF8.GetString(www.bytes);
            if (!existAssetCache)
            {
                createCache(url, json, BumResourceType.eBumResourceType_userInfo);
            }

            onloaded(json);
        } while (false);
        www.Dispose();
        www = null;
    }
Exemplo n.º 6
0
    private IEnumerator loadAssetBundleFormWWW(string url, Action <object> onloaded, Action <object> progressEvent, bool existAssetCache = false, object param = null, Action <GameObject, object> beforeClone = null)
    {
        string path = url;

        if (existAssetCache)
        {
            path = BumDefine.bumAssetBundlePathFile + BumDefine.getFileByUrl(url) + "/product";
        }

        WWW www = new WWW(path);

        while (!www.isDone)
        {
            if (progressEvent != null)
            {
                progressEvent(www.progress);
            }
            yield return(null);
        }

        do
        {
            if (!string.IsNullOrEmpty(www.error))
            {
                BumBase.Log(www.error);
                break;
            }

            AssetBundle bundle = www.assetBundle;
            if (bundle == null)
            {
                break;
            }

            UnityEngine.Object[] objs = bundle.LoadAllAssets();

            for (int i = 0; i < objs.Length; i++)
            {
                if (!objs[i].GetType().Equals(typeof(GameObject)))
                {
                    continue;
                }
                //if (!objs[i].name.Equals("product")) continue;

                GameObject data = objs[i] as GameObject;
                data.name = BumDefine.getIdByUrl(url);

                //pool.addData(path,data, BumResourceType.eBumResourceType_assetBundle);

                //if (!existAssetCache) createCache(url,www.bytes,BumResourceType.eBumResourceType_assetBundle);
                if (beforeClone != null)
                {
                    beforeClone(data, param);
                }
                if (onloaded != null)
                {
                    onloaded(data);
                }
            }

            bundle.Unload(false);
        } while (false);
        www.Dispose();
        www = null;
    }