Example #1
0
        public IEnumerator DownloadAssetBundle(string sku, AssetBundleDownloadCallback callback)
        {
            if (useCache)
            {
                updateProductQueue(sku);
            }

            string path    = DataUtility.GetProductModelPath() + sku;
            string url     = "";
            bool   existed = File.Exists(path);

            if (useCache && existed)
            {
                url = "file://" + path;
            }
//				url = path;
            else
            {
//#if UNITY_ANDROID
//                url = Tags.AndroidEcModelUrl + sku;
//#elif UNITY_IOS
//            url = Tags.AndroidEcModelUrl + sku;
//#endif
                //test
                url = baseUrl + "/magento/model/" + EncodeUriComponent(sku);
                Debug.Log("url = " + url);
            }

            WWW www = new WWW(url);

            yield return(www);

            try
            {
                if (www.assetBundle != null)
                {
                    Debug.Log("www.assetBundle != null");
                    System.Object[] objs = www.assetBundle.LoadAllAssets();
                    if (useCache)
                    {
                        File.WriteAllBytes(path, www.bytes);
                    }
                    callback(sku, objs);
                }
                else
                {
                    Debug.Log("www.assetBundle == null");
                    System.Object[] objs = new System.Object[] { DataController.Singleton.defaultModel };
                    callback(sku, objs);
                }
            }
            catch (Exception ex)
            {
                Debug.Log("load asset error: " + ex.Message);
            }
        }
Example #2
0
        public IEnumerator DownloadAssetBundle(string sku, AssetBundleDownloadCallback callback)
        {
            bool toEnd = false;

            yield return(null);

            foreach (Category cat in catList)
            {
                foreach (CategoryProduct cp in cat.Products)
                {
                    if (cp.sku == sku)
                    {
                        System.Object ta = Resources.Load("Products/" + cat.name + "/" + cp.sku);
                        callback(sku, new System.Object[] { ta });
                        toEnd = true;
                        break;
                    }
                }

                //test
                foreach (SubCategory scat in cat.SubCategorys)
                {
                    foreach (CategoryProduct cp in scat.Products)
                    {
                        if (cp.sku == sku)
                        {
                            System.Object ta = Resources.Load("Products/" + scat.parent_name + "/" + scat.sub_name + "/" + cp.sku);
                            callback(sku, new System.Object[] { ta });
                            toEnd = true;
                            break;
                        }
                    }
                }


                if (toEnd)
                {
                    break;
                }
            }
        }
Example #3
0
 public void DownloadAssetBundle(string sku, AssetBundleDownloadCallback callback)
 {
     StartCoroutine(collector.DownloadAssetBundle(sku, callback));
 }