示例#1
0
    /// <summary>
    ///  定时器下,在每帧对下载队列进行检测
    ///  如果下载有问题,或者超时,则清除
    ///  如果下载完成,则解析下载结果,并进入completeDict中
    /// </summary>
    public void CheckQueue()
    {
        if (!isLoading)
        {
            return;
        }
        foreach (KeyValuePair <string, LoadRequest> pair in loadDict)
        {
            LoadRequest request = pair.Value;
            request.loadTotalFrames++;

            // deal error
            if ((request.wwwObject != null && request.wwwObject.error != null) || request.isTimeOut)
            {
                if (request.requestURL.Contains(".apk") || request.requestURL.Contains(".ipa"))
                {
                    return;
                }

                request.alreadyDeal = true;
                loadDict.Remove(request.requestURL);
                ErrorDelegateHandle(request);
                if (request.isTimeOut)
                {
                    Debug.LogWarning("Load time out:" + request.requestURL);
                }
                else
                {
                    Debug.LogWarning("Load error:" + request.requestURL);
                }

                MoveRequestFromWaitDictToLoadDict();
                break;
            }

            //
            if (!request.alreadyDeal)
            {
                ProcessDelegateHandle(request);
                // if done
                if (request.wwwObject != null && request.wwwObject.isDone)
                {
                    LoadParam param = ParseLoadParamFromLoadRequest(request);
                    if (request.fileType != LoadFileType.BINARY)
                    {
                        completeDict.Add(request.requestURL, param);
                    }
                    //
                    CompleteDelegateHandle(request, param);
                    //
                    request.alreadyDeal = true;
                    loadDict.Remove(request.requestURL);
                    MoveRequestFromWaitDictToLoadDict();
                    break;
                }
            }
        }
    }
示例#2
0
        // 测试 .anim 动画
        protected void testAnim()
        {
            LoadParam param   = Ctx.m_instance.m_poolSys.newObject <LoadParam>();
            string    resPath = "Anim/boxcampush";

            LocalFileSys.modifyLoadParam(resPath, param);
            param.m_loadEventHandle = onLoadEventHandle;
            Ctx.m_instance.m_resLoadMgr.loadResources(param);
            Ctx.m_instance.m_poolSys.deleteObj(param);
        }
示例#3
0
        // 异步加载
        public void loadBT(BTID id)
        {
            LoadParam param = Ctx.m_instance.m_poolSys.newObject <LoadParam>();

            LocalFileSys.modifyLoadParam(m_btAttrSys.m_id2ItemDic[id].m_path, param);
            param.m_loadNeedCoroutine = false;
            param.m_resNeedCoroutine  = false;
            load <BehaviorTreeRes>(param);
            Ctx.m_instance.m_poolSys.deleteObj(param);
        }
示例#4
0
    // Update is called once per frame
    void OnGUI()
    {
        //设置按钮中文字的颜色
        GUI.color = Color.green;
        //设置按钮的背景色
        GUI.backgroundColor = Color.red;

        if (GUI.Button(new Rect(10, 50, 100, 200), "aaa"))
        {
            //开始游戏按钮被按下
            //GameObject.Destroy(this);//销毁这个脚本
            LoadParam param = Ctx.m_instance.m_poolSys.newObject <LoadParam>();
            param.m_path        = "Level1.unity3d";
            param.m_resPackType = ResPackType.eLevelType;
            Ctx.m_instance.m_resLoadMgr.load(param);
            Ctx.m_instance.m_poolSys.deleteObj(param);
        }
    }
示例#5
0
 /// <summary>
 ///  任务下载完成回调
 /// </summary>
 /// <param name="request"></param>
 /// <param name="param"></param>
 public void CompleteDelegateHandle(LoadRequest request, LoadParam param)
 {
     if (request.completeFunction != null)
     {
         int count = request.completeFunction.GetInvocationList().GetLength(0);
         for (int i = 0; i < count; i++)
         {
             if (i < request.customParams.Count)
             {
                 param.param = request.customParams[i];
             }
             LoadRequest.DownCompleteDelegate completeFunc = (LoadRequest.DownCompleteDelegate)request.completeFunction.GetInvocationList()[i];
             try
             {
                 completeFunc.Invoke(param);
             }
             catch (Exception exception)
             {
                 Debug.LogWarning("exception:" + exception.Message);
             }
         }
     }
 }
示例#6
0
    /// <summary>
    ///  解析下载内容
    /// </summary>
    public LoadParam ParseLoadParamFromLoadRequest(LoadRequest request)
    {
        LoadParam param = new LoadParam();

        param.url      = request.requestURL;
        param.priotiry = request.priotiry; // 为何param需要记录优先级?
        param.fileType = request.fileType;

        switch (request.fileType)
        {
        case LoadFileType.IMAGE:
            try
            {
                param.texture2D = request.wwwObject.texture;
                param.texture2D.Compress(false);        // compress 有何影响
            }
            catch (Exception exception)
            {
                Debug.LogWarning("read texture2d error:" + request.requestURL + "\n" + exception.Message);
            }
            break;

        case LoadFileType.TXT:
            try
            {
                param.text = request.wwwObject.text;
            }
            catch (Exception exception)
            {
                Debug.LogWarning("read text error:" + request.requestURL + "\n" + exception.Message);
            }
            break;

        case LoadFileType.UNITY3D:
            try
            {
                if (request.wwwObject.assetBundle != null)
                {
                    param.assetBundle = request.wwwObject.assetBundle;
                }
            }
            catch (Exception exception)
            {
                Debug.LogWarning("read assetBundle error:" + request.requestURL + "\n" + exception.Message);
            }
            break;

        case LoadFileType.MODULE_RESOURCE:
            try
            {
                //UnityEngine.Object[] data = request.wwwObject.assetBundle.LoadAllAssets();
                //int length = data.Length;
                //for (int i = 0; i < length; i++)
                //{
                //    if (data[i] is GameObject)
                //    {
                //        param.uiAtlas = (data[i] as GameObject).GetComponent<UIAtlas>();
                //        break;
                //    }
                //}
                //request.wwwObject.assetBundle.Unload(false);
            }
            catch (Exception exception)
            {
                Debug.LogWarning("read uiatlas error:" + request.requestURL + "\n" + exception.Message);
            }
            break;

        case LoadFileType.JSON:
            try
            {
                param.jsonData = request.wwwObject.text.Trim();
            }
            catch (Exception exception)
            {
                Debug.LogWarning("read  json error:" + request.requestURL + "\n" + exception.Message);
            }
            break;

        case LoadFileType.FBX:
            try
            {
                param.mainAsset = request.wwwObject.assetBundle.mainAsset;
            }
            catch (Exception exception)
            {
                Debug.LogWarning("read  fbx error:" + request.requestURL + "\n" + exception.Message);
            }
            break;

        case LoadFileType.BINARY:
        case LoadFileType.BINARY_BG:
            try
            {
                param.byteArr = request.wwwObject.bytes;
            }
            catch (Exception exception)
            {
                Debug.LogWarning("read  binary error:" + request.requestURL + "\n" + exception.Message);
            }
            break;

        case LoadFileType.AUDIO:
            try
            {
                UnityEngine.Object[] data = request.wwwObject.assetBundle.LoadAllAssets();
                int length = data.Length;
                for (int i = 0; i < length; i++)
                {
                    if (data[i] is AudioClip)
                    {
                        param.audioClip = data[i] as AudioClip;
                        break;
                    }
                }
                request.wwwObject.assetBundle.Unload(false);
            }
            catch (Exception exception)
            {
                Debug.LogWarning("read audio error:" + request.requestURL + "\n" + exception.Message);
            }
            break;

        case LoadFileType.FONT:
            try
            {
                //UnityEngine.Object[] data = request.wwwObject.assetBundle.LoadAllAssets();
                //int length = data.Length;
                //for (int i = 0; i < length; i++)
                //{
                //    if (data[i] is UnityEngine.Transform)
                //    {
                //        param.font = (data[i] as UnityEngine.Transform).GetComponent<UIFont>();
                //        break;
                //    }
                //}
                //request.wwwObject.assetBundle.Unload(false);
            }
            catch (Exception exception)
            {
                Debug.LogWarning("read  font error:" + request.requestURL + "\n" + exception.Message);
            }
            break;
        }
        return(param);
    }
示例#7
0
    public IEnumerator LoadAndSetupFromAssetSet(List <ActAssetSet> assetSetList, LoadParam param, Action <LoadResult> endCb) => default;   // 0x0093D110-0x0093D1A0

    // [IteratorStateMachine] // 0x00618E00-0x00618E70
    public IEnumerator LoadAndSetupFromAssetSet(List <string> assetSetSymbolList, LoadParam param, Action <LoadResult> endCb) => default;   // 0x0093D1A0-0x0093D220
示例#8
0
    public IEnumerator LoadAndSetupFromAssetSet(ActAssetSet assetSet, LoadParam param, Action <LoadResult> endCb) => default;    // 0x0093D080-0x0093D110

    // [IteratorStateMachine] // 0x00618D90-0x00618E00
    public IEnumerator LoadAndSetupFromAssetSet(List <ActAssetSet> assetSetList, LoadParam param, Action <LoadResult> endCb) => default;   // 0x0093D110-0x0093D1A0
示例#9
0
    public List <ActObjBase> EnumActObj() => default;    // 0x0093D020-0x0093D080

    // [IteratorStateMachine] // 0x00618D20-0x00618D90
    public IEnumerator LoadAndSetupFromAssetSet(ActAssetSet assetSet, LoadParam param, Action <LoadResult> endCb) => default;    // 0x0093D080-0x0093D110