Esempio n. 1
0
    static int MD5Data(IntPtr L)
    {
        L.ChkArgsCount(1);
        byte[] objs0 = L.ToArrayNumber <byte>(1);
        string o     = CMD5.MD5Data(objs0);

        L.PushString(o);
        return(1);
    }
Esempio n. 2
0
        protected override IEnumerator PerformTask(AsyncLoadingTask task, ABRefOut output)
        {
            string suitPath = "";
            string abName   = task.assetbundleName;

            if (!task.forcedStreaming)
            {
                suitPath = Path.Combine(bundleRootPath, abName);
            }
            if (!File.Exists(suitPath))
            {
                suitPath = Path.Combine(streamingRootPath, abName);
            }
            if (!suitPath.Contains("://"))
            {
                if (suitPath.Contains(":"))
                {
                    suitPath = "file:///" + suitPath;
                }
                else
                {
                    suitPath = "file://" + suitPath;
                }
            }

            WWW www = new WWW(suitPath);

            yield return(www);

            if (www.error == null)
            {
                // 把资源缓存到persistentDataPath
                output.transfer = new AssetsTransfer(www.bytes, Path.Combine(bundleRootPath, abName));

                if (task.needMD5)
                {
                    output.md5 = CMD5.MD5Data(www.bytes);
                }
                AssetBundle ab = www.assetBundle;
                if (ab != null)
                {
                    //// 资源是一个AssetBundle,获取Bundle里的所有Assets, 保存
                    //AssetBundleRequest abReq = ab.LoadAllAssetsAsync();
                    //while (!abReq.isDone) {
                    //    if (progressView && progressView.gameObject.activeInHierarchy) {
                    //        progressView.value = abReq.progress;
                    //    }
                    //    yield return 1;
                    //}
                    //if (progressView && progressView.gameObject.activeInHierarchy) {
                    //    progressView.value = 1;
                    //}

                    if (output.abRef == null)
                    {
                        output.abRef = new AssetBundleRef(abName, ab, task.allowUnload);
                    }
                    else
                    {
                        var abRef = output.abRef as AssetBundleRef;
                        abRef.Init(abName, ab, task.allowUnload);
                    }
                }
            }
        }