Esempio n. 1
0
        /// <summary>
        ///  (同步)加载.text 文件 并以string 形式返回
        /// </summary>
        /// <param name="requestTarget">请求加载资源的对象</param>
        /// <param name="url"></param>
        /// <param name="completeHandler"></param>
        /// <returns></returns>
        public static TextAssetLoader LoadAssetSync(string url, System.Action <BaseAbstracResourceLoader> completeHandler)
        {
            if (string.IsNullOrEmpty(url))
            {
                Debug.LogError(string.Format("Url Can't Be Null , TypeLoader={0}", typeof(TextAsset)));
                return(null);
            }
            bool            isContainLoaders = false;
            TextAssetLoader textAssetLoader  = ResourcesLoaderMgr.GetOrCreateLoaderInstance <TextAssetLoader>(url, ref isContainLoaders);

            textAssetLoader.m_OnCompleteAct.Add(completeHandler);


            textAssetLoader.AddReference(null, url);
            if (isContainLoaders && textAssetLoader.IsCompleted)
            {
                textAssetLoader.LoadassetModel = LoadAssetModel.Sync;
                textAssetLoader.OnCompleteLoad(textAssetLoader.IsError, textAssetLoader.Description, textAssetLoader.ResultObj, textAssetLoader.IsCompleted);
                return(textAssetLoader);
            }

            if (textAssetLoader.LoadassetModel == LoadAssetModel.Async)
            {
                textAssetLoader.ForceBreakLoaderProcess();
            }
            textAssetLoader.LoadassetModel       = LoadAssetModel.Sync;
            textAssetLoader.m_LoadAssetCoroutine = null;
            textAssetLoader.LoadTextAssetSync(url);
            return(textAssetLoader);
        }
Esempio n. 2
0
        /// <summary>
        /// 卸载指定的资源
        /// </summary>
        /// <param name="url"></param>
        /// <param name="requestTarget">为null 则卸载加载时候请求的对象</param>
        public static void UnLoadAsset(string url, bool isForceDelete = false)
        {
            TextAssetLoader textAssetLoader = ResourcesLoaderMgr.GetExitLoaderInstance <TextAssetLoader>(url);

            if (textAssetLoader == null)
            {
                //Debug.LogError("无法获取指定类型的加载器 " + typeof(TextAssetLoader));
                return;
            }
            textAssetLoader.ReduceReference(textAssetLoader, isForceDelete);
        }