当前位置: 首页>>代码示例>>C#>>正文


C# Mission.Done方法代码示例

本文整理汇总了C#中Mission.Done方法的典型用法代码示例。如果您正苦于以下问题:C# Mission.Done方法的具体用法?C# Mission.Done怎么用?C# Mission.Done使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mission的用法示例。


在下文中一共展示了Mission.Done方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: _DownloadAssetImpl

    IEnumerator _DownloadAssetImpl(Mission mission)
    {
        mCurMission = mission;

        string bundleName = mission.CurrentBundle.ToLower();
        DownloadedCB cb_PerBundleLoaded = mission.PerloadedCB;
        AllDownloadedCB cb_all = mission.AllLoadedCB;
        AssetBundle bundle = GetCached(bundleName);

        string url = "";
        if (bundle == null)
        {
            // 尝试从本地读取文件
            bool bLocalNew = IsLocalNewVersion(bundleName);
            if (bLocalNew)
                url = GetLocalPath(ly.AssetDependencyManager.GetPackagePath(bundleName));
            else
                url = GetHttpPath(ly.AssetDependencyManager.RealPath2PackagePath(bundleName));

            // 如果本地已经更新,并且没有设置回调,则直接跳过
            if (!bLocalNew || cb_PerBundleLoaded != null)
            {
                WWW downloading = new WWW(url);
                mission.CurrentDownloading = downloading;
                yield return downloading;

                if (downloading.error != null)
                {
                    UIHelper.ShowMessage("Download error:"+downloading.error+", file:"+url+", make sure your asset is in the main bundle.");
                }
                else
                {
                    Debug.Log("Bundle has been downloaded! file:"+url);

                    // 有回调函数设置,才认为需要立即加载到内存
                    if (cb_PerBundleLoaded != null)
                        bundle = downloading.assetBundle;

                    // 如果远程下载了文件,则保存到本地
                    if (!bLocalNew)
                    {
                        string path = GetLocalPathNoPrefix(ly.AssetDependencyManager.GetPackagePath(bundleName));
                        string dir = System.IO.Path.GetDirectoryName(path);
                        if (!System.IO.Directory.Exists(dir))
                            System.IO.Directory.CreateDirectory(dir);
                        System.IO.FileStream stream = new System.IO.FileStream(path, System.IO.FileMode.Create);
                        stream.Write(downloading.bytes, 0, downloading.bytes.Length);
                        stream.Flush();
                        stream.Close();

                        string MD5 = GetMD5(downloading.bytes);
                        UpdateLocalMD5(bundleName, MD5);

                        // 每下载一个资源文件,都更新一下本地的VersionFile,防止中途退出又要重新下载
                        UpdateLocalVersionFile();
                    }

                    if (bundle != null)
                        mCacheBundle.Add(bundleName, bundle);
                }
            }
        }
        else
        {
            Debug.Log("Bundle has been loaded! file:"+bundleName);
        }

        if (cb_PerBundleLoaded != null && bundle == null)
        {
            Debug.LogError("No bundle!"+url);
        }

        mission.Done();
        if (cb_PerBundleLoaded != null)
            cb_PerBundleLoaded(bundleName, bundle, null, mission.mUserData);

        if (!mission.IsCompleted())
        {
            this.StartCoroutine(_DownloadAssetImpl(mission));
        }
        else
        {
            if (cb_all != null)
                cb_all(bundleName, mission.mUserData);

            mMissionList.RemoveFirst();
            if (mMissionList.Count > 0)
            {
                mission = mMissionList.First.Value;
                this.StartCoroutine(_DownloadAssetImpl(mission));
            }
        }
    }
开发者ID:GHunique,项目名称:MyU3dFrame,代码行数:93,代码来源:AssetManager.cs


注:本文中的Mission.Done方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。