/// <summary> /// 加载模型资源 /// </summary> /// <param name="path">Data/Model/HeroModel/{0}</param> /// <param name="callBackFun"></param> /// <param name="assetPRIType"></param> /// <returns></returns> public IAssetRequest LoadModel(string path, AssetRequestFinishedEventHandler callBackFun, AssetPRI assetPRIType) { IAssetRequest result; if (string.IsNullOrEmpty(path)) { AssetLogger.Error("string.IsNullOrEmpty(path) == true"); result = null; } else { string name = LocalResourceManager.ChangePathToFilenameWithoutExtension(path); ResourceData resourceData = null; List <ResourceData> dependes = null; CollectDepResourceData collectDepResourceData = this.m_DicModelResourceData.GetCollectDepResourceData(name, out resourceData, out dependes); if (null != collectDepResourceData) { result = this.CreateAssetRequest(resourceData, dependes, callBackFun, assetPRIType); } else { AssetLogger.Error(string.Format("null == collectDepResourceData:{0}", path)); result = null; } } return(result); }
/// <summary> /// 将路径转化成文件名不带后缀,将/转成_ /// </summary> /// <param name="path"></param> /// <returns></returns> public static string ChangePathToFilenameWithoutExtension(string path) { path = LocalResourceManager.FormatPath(path); string text = path.Replace('/', '_'); text = text.Replace(" ", ""); return(Path.GetFileNameWithoutExtension(text)); }
public static LocalResourceManager GetInstance() { if (LocalResourceManager.instance == null) { GameObject gameObject = new GameObject("WWWResourceManager"); UnityEngine.Object.DontDestroyOnLoad(gameObject); LocalResourceManager.instance = gameObject.AddComponent <LocalResourceManager>(); } return(LocalResourceManager.instance); }
public IAssetRequest CreateAssetRequest(string path, AssetRequestFinishedEventHandler callback, AssetPRI assetPRI, EnumAssetType assetType) { if (string.IsNullOrEmpty(path)) { AssetLogger.Error("string.IsNullOrEmpty(path) == true"); return(null); } string arg = Path.GetDirectoryName(path).ToLower(); string text = LocalResourceManager.ChangePathToFilenameWithoutExtension(path); path = string.Format("data/{0}/{1}.ab", arg, text); ResourceData resourceData = CollectDepResourceDataMap.RefResource(text, path, 0, assetType); return(this.CreateAssetRequest(resourceData, null, callback, assetPRI)); }
/// <summary> /// 构造函数,初始化需要下载的资源和下载完成之后的委托回调 /// </summary> /// <param name="assetCollectDepResource"></param> /// <param name="handler"></param> public LocalAssetRequest(IAssetCollectDepResource assetCollectDepResource, AssetRequestFinishedEventHandler handler) { LocalAssetCollectDepResource colldepResource = assetCollectDepResource as LocalAssetCollectDepResource; if (colldepResource == null || colldepResource.GetAssetResource() == null) { this.m_isErroe = true; return; } this.handler = handler; this.m_assetCollectDepResource = colldepResource; this.m_assetCollectDepResource.AddAssetRequest(this); if (handler != null && this.m_assetCollectDepResource.HasCallBack()) { LocalResourceManager.GetInstance().StartCoroutine(this.DelayCallBack(handler, this)); } }
public IAssetRequest LoadScene(string path, AssetRequestFinishedEventHandler callBackFun, AssetPRI assetPRIType) { IAssetRequest result; if (string.IsNullOrEmpty(path)) { AssetLogger.Error("string.IsNullOrEmpty(path) == true"); result = null; } else { string directoryName = Path.GetDirectoryName(path); string text = LocalResourceManager.ChangePathToFilenameWithoutExtension(path); path = string.Format("data/{0}/{1}.unity3d", directoryName, text); ResourceData resourceData = CollectDepResourceDataMap.RefResource(text, path, 0, EnumAssetType.eAssetType_Scene); result = this.CreateAssetRequest(resourceData, null, callBackFun, assetPRIType); } return(result); }
public IAssetRequest LoadEffect(string path, AssetRequestFinishedEventHandler callback, AssetPRI assetPRI) { if (string.IsNullOrEmpty(path)) { AssetLogger.Error("string.IsNullOrEmpty(path) == true"); return(null); } string name = LocalResourceManager.ChangePathToFilenameWithoutExtension(path); ResourceData resourceData = null; List <ResourceData> list = null; CollectDepResourceData collectDepResourceData = this.m_DicEffectReourceData.GetCollectDepResourceData(name, out resourceData, out list); if (collectDepResourceData != null) { return(this.CreateAssetRequest(resourceData, list, callback, assetPRI)); } AssetLogger.Error(string.Format("null == collectDepResourceData:{0}", path)); return(null); }
/// <summary> /// 加载UI资源 /// </summary> /// <param name="path"></param> /// <param name="callback"></param> /// <param name="assetPRI"></param> /// <returns></returns> public IAssetRequest LoadUI(string path, AssetRequestFinishedEventHandler callback, AssetPRI assetPRI) { if (string.IsNullOrEmpty(path)) { AssetLogger.Error("string.IsNullOrEmpty(path) == true"); return(null); } string text = LocalResourceManager.ChangePathToFilenameWithoutExtension(path);//路径转成文件名不带后缀 ResourceData resourceData = null; List <ResourceData> dependes = null; CollectDepResourceData collectDepResourceData = this.m_DicUIResourceData.GetCollectDepResourceData(text, out resourceData, out dependes); if (collectDepResourceData != null) { return(this.CreateAssetRequest(resourceData, dependes, callback, assetPRI));//创建请求资源实例 } AssetLogger.Error(string.Format("null == collectDepResourceData:{0}", text)); return(null); }