/// <summary> /// 加载Texture2D 图片 /// </summary> /// <param name="url"></param> /// <param name="completeHandler"></param> /// <returns></returns> public static Teture2DLoader LoadTexture2DAssetSync(Transform requestTarget, string url, System.Action <BaseAbstracResourceLoader> completeHandler) { Debug.LogError("TODO Teture2DLoader 还不完善 需要继续测试 "); if (string.IsNullOrEmpty(url)) { Debug.LogError(string.Format("Url Can't Be Null , TypeLoader={0}", typeof(Teture2DLoader))); return(null); } bool isContainLoaders = false; Teture2DLoader texture2DLoader = ResourcesLoaderMgr.GetOrCreateLoaderInstance <Teture2DLoader>(url, ref isContainLoaders); texture2DLoader.m_OnCompleteAct.Add(completeHandler); texture2DLoader.AddReference(requestTarget, url); if (isContainLoaders && texture2DLoader.IsCompleted) { texture2DLoader.LoadassetModel = LoadAssetModel.Sync; texture2DLoader.OnCompleteLoad(texture2DLoader.IsError, texture2DLoader.Description, texture2DLoader.ResultObj, texture2DLoader.IsCompleted); return(texture2DLoader); } if (texture2DLoader.LoadassetModel == LoadAssetModel.Async) { texture2DLoader.ForceBreakLoaderProcess(); } texture2DLoader.LoadassetModel = LoadAssetModel.Sync; texture2DLoader.m_LoadAssetCoroutine = null; texture2DLoader.LoadTexture2DAssetSync(url); return(texture2DLoader); }
/// <summary> /// 卸载资源 /// </summary> /// <param name="url"></param> /// <param name="requestTarget"></param> public static void UnLoadAsset(string url, object requestTarget = null) { Teture2DLoader texture2DLoader = ResourcesLoaderMgr.GetExitLoaderInstance <Teture2DLoader>(url); if (texture2DLoader == null) { //Debug.LogError("无法获取指定类型的加载器 " + typeof(Teture2DLoader)); return; } if (requestTarget == null) { requestTarget = texture2DLoader.m_RequesterTarget; } texture2DLoader.ReduceReference(texture2DLoader, false); }