Exemplo n.º 1
0
        public IEnumerator DownLoadAsset(string assetName, DownLoadHelp downLoadHelper)
        {
            bool   fromLocal = Application.isEditor;
            string loadpath  = string.Format("file://{0}/{1}", Application.streamingAssetsPath, assetName);

            if (!fromLocal)
            {
                loadpath = string.Format("https://{0}/{1}", Application.streamingAssetsPath, assetName);
            }

            WWW assetData = new WWW(loadpath);

            yield return(assetData);

            if (assetData.error != null)
            {
                Debug.Log(assetData.error);
                yield break;
            }
            AssetBundle assetBundle;

            if (assetData.isDone)
            {
                assetBundle = AssetBundle.LoadFromMemory(assetData.bytes);
                Assert.AreNotEqual(assetData, null);
                BundleReference bundleReference = new BundleReference();
                bundleReference.InitBundle(assetBundle);
                bundlelist.Add(assetName, bundleReference);
                downLoadHelper.OnLoadAssetBundle(assetBundle);
            }
            yield return(null);
        }
Exemplo n.º 2
0
        public IEnumerator LoadAssetBundle(string keyName, CombineDownLoadHelp combineLoadHelp)
        {
            AssetBundle assetBundle = null;
            bool        hasBundle   = bundlelist.ContainsKey(keyName) && bundlelist[keyName].Bundle != null;

            if (!hasBundle)
            {
                DownLoadHelp downLoadHelp = new DownLoadHelp();
                yield return(DownLoadAsset(keyName, downLoadHelp));
            }

            if (bundlelist.ContainsKey(keyName))
            {
                assetBundle = bundlelist[keyName].PlusCount();
            }
            if (assetBundle != null)
            {
                combineLoadHelp.OnLoadAssetBundle(assetBundle);
            }
            yield return(null);
        }