using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using LuaInterface; using GameCore; namespace GameLogic { /// /// 资源管理器 /// public class ResourcesManager : Singleton { public bool isLoading; ResMgr.ResourcesManager resMgr = ResMgr.ResourcesManager.Instance; /// /// 初始化 /// public void Initialize(bool isReleaseVer) { //资源路径配置 ResMgr.ResConfig.PersistentDataPath = AppConst.PersistentDataPath; ResMgr.ResConfig.StreamPath = AppConst.StreamPath; resMgr.Init(isReleaseVer); Debug.LogFormat("================>ResourcesManager.Initialize,isReleaseVer:{0}",isReleaseVer); } /// /// 同步加载资源 /// /// 资源类型 /// 资源名 /// [NoToLua] public T LoadAsset(string assetName) where T : Object { return resMgr.LoadAsset(assetName); } /// /// 同步加载资源 /// /// 资源名 /// public Object LoadAsset(string assetName) { return resMgr.LoadAsset(assetName); } /// /// 异步加载资源 /// /// /// /// [NoToLua] public void LoadAssetAsync(string assetName, UnityAction action) where T : Object { resMgr.LoadAssetAsync(assetName, action); } /// /// 异步加载资源 /// /// /// [NoToLua] public void LoadAssetAsync(string assetName, UnityAction action) { resMgr.LoadAssetAsync(assetName, action); } /// /// Lua异步加载资源 /// /// /// public void LoadAssetAsync(string assetName, LuaFunction luaFunction) { resMgr.LoadAssetAsync(assetName, (name, obj) => { if (luaFunction != null) { luaFunction.Call(name, obj); } }); } /// /// 卸载资源 /// /// public void UnLoadAsset(string assetName) { resMgr.UnLoadAsset(assetName); } /// /// 卸载游戏 /// public void UnLoadGame() { resMgr.UnLoadAll(); } /// /// 卸载没有使用的资源和AssetBundle /// public void UnLoadUnUseAssetAndAssetBundle() { resMgr.UnLoadUnUseAssetAndAssetBundle(); } /// /// 是否拥有某个资源 /// /// 资源名 /// public bool HaveAsset(string asset) { return resMgr.HaveAsset(asset); } /// /// 卸载掉所有资源(平台和游戏) /// public void UnLoadAll() { resMgr.UnLoadAll(); } public void Reset() { } } }