Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            Debug.LogInfor("Time=" + Time.realtimeSinceStartup + "Frame=" + EventCenter.Instance.CurFrameCount);
            TextAssetLoader loader = TextAssetLoader.LoadAsset(m_Url, m_LoadAssetModel, OnComplete);
        }

        if (Input.GetKeyDown(KeyCode.B))
        {
            if (m_LoadAssetModel == LoadAssetModel.Async)
            {
                ResourcesMgr.Instance.LoadFileAsync(m_Url, (result) => { m_ShowText.text = result; });
            }
            else
            {
                m_ShowText.text = ResourcesMgr.Instance.LoadFileSync(m_Url);
            }
        }
    }
Ejemplo n.º 2
0
        /// <summary>
        /// 加载各种配置文件(配置文件只会被加载一次 ,加载后不会被主动销毁)
        /// </summary>
        /// <param name="url"></param>
        /// <param name="callback"></param>
        private void LoadFile(string url, LoadAssetModel loadModel, System.Action <string> callback)
        {
            TextAssetLoader.LoadAsset(url, loadModel, (loader) =>
            {
                ResourcesLoadTraceMgr.Instance.RecordTraceResourceInfor(loader);
                #region  加载成功后的处理逻辑
                if (loader == null || (loader.IsCompleted && loader.IsError))
                {
                    Debug.LogInfor("LoadFile   Fail,Not Exit At Path= " + url);
                    if (callback != null)
                    {
                        callback.Invoke(null);
                    }
                    return;
                } //加载资源出错

                if (callback != null)
                {
                    callback.Invoke(loader.ResultObj.ToString());
                }
                #endregion
            });
        }