Beispiel #1
0
        /// <summary>
        /// (同步)加载材质球资源
        /// </summary>
        /// <param name="url"></param>
        /// <param name="completeHandler"></param>
        /// <returns></returns>
        protected static MaterialLoader LoadAssetSync(Transform requestTarget, string url, System.Action <BaseAbstracResourceLoader> completeHandler)
        {
            if (string.IsNullOrEmpty(url))
            {
                Debug.LogError(string.Format("Url Can't Be Null , TypeLoader={0}", typeof(MaterialLoader)));
                return(null);
            }

            bool           isContainLoaders = false;
            MaterialLoader materialLoader   = ResourcesLoaderMgr.GetOrCreateLoaderInstance <MaterialLoader>(url, ref isContainLoaders);

            materialLoader.m_OnCompleteAct.Add(completeHandler);


            materialLoader.AddReference(requestTarget, url);
            if (isContainLoaders && materialLoader.IsCompleted)
            {
                materialLoader.LoadassetModel = LoadAssetModel.Sync; //这里貌似没必要(由于异步加载时候同步加载必定完成了)
                materialLoader.OnCompleteLoad(materialLoader.IsError, materialLoader.Description, materialLoader.ResultObj, materialLoader.IsCompleted);
                return(materialLoader);
            }
            if (materialLoader.LoadassetModel == LoadAssetModel.Async)
            {
                materialLoader.ForceBreakLoaderProcess();
            }
            materialLoader.m_LoadAssetCoroutine = null;
            materialLoader.LoadassetModel       = LoadAssetModel.Sync; //这里貌似没必要
            materialLoader.LoadMaterialAssetSync(url);
            return(materialLoader);
        }
Beispiel #2
0
        public static void UnLoadAsset(string url, object requestTarget = null)
        {
            MaterialLoader materialLoader = ResourcesLoaderMgr.GetExitLoaderInstance <MaterialLoader>(url);

            if (materialLoader == null)
            {
                //Debug.LogError("无法获取指定类型的加载器 " + typeof(materialLoader));
                return;
            }
            if (requestTarget == null)
            {
                requestTarget = materialLoader.m_RequesterTarget;
            }

            materialLoader.ReduceReference(materialLoader, false);
        }