public string getAbsPathByRelPath(ref string relPath, ref ResLoadType loadType) { // 获取版本 string version = Ctx.m_instance.m_versionSys.getFileVer(relPath); string absPath = relPath; if (!string.IsNullOrEmpty(version)) { absPath = UtilLogic.combineVerPath(Path.Combine(Ctx.m_instance.m_localFileSys.getLocalWriteDir(), relPath), version); if (!File.Exists(absPath)) { absPath = Path.Combine(Ctx.m_instance.m_localFileSys.getLocalReadDir(), relPath); if (!File.Exists(absPath)) { absPath = ""; } else { loadType = ResLoadType.eStreamingAssets; } } else { relPath = UtilLogic.combineVerPath(relPath, version); // 在可写目录下,文件名字是有版本号的 loadType = ResLoadType.ePersistentData; } } else { loadType = ResLoadType.eStreamingAssets; } return(absPath); }
public static string GetPath(string localPath, ResLoadType loadType) { StringBuilder path = new StringBuilder(); switch (loadType) { case ResLoadType.Streaming: #if UNITY_EDITOR path.Append(Application.dataPath); path.Append("/StreamingAssets/"); break; #else path.Append(Application.streamingAssetsPath); path.Append("/"); break; #endif case ResLoadType.Persistent: path.Append(Application.persistentDataPath); path.Append("/"); break; } path.Append(localPath); path.Append(".assetBundle"); return(path.ToString()); }
//保存一个文本 public static void WriteTextFile(string path, string content, ResLoadType type) { #if UNITY_EDITOR ResourceIOTool.WriteStringByFile(GetPath(path, type), content); #else #endif }
//保存一个文本 public static void WriteTextFile(string path, string content, ResLoadType type) { #if UNITY_EDITOR ResourceIOTool.WriteStringByFile(PathTool.GetAbsolutePath(type, path), content); #else #endif }
/// <summary> /// 根据策划资源表的主键加载到POOL /// </summary> /// <param name="entityResType">对应资源表主键</param> /// <returns></returns> public GameObjectPool GetGameObjectPool(int entityResType) { GameObjectPool pool = null; if (!gameObjectPools.TryGetValue(entityResType, out pool)) { var cell = Config.resourceConfig.getInstace().getCell(entityResType); if (null == cell) { string e = string.Format("资源表没有这个资源 {0}", entityResType); throw new System.Exception(e); } ResLoadType eResLoadType = (ResLoadType)cell.loadtype; switch (eResLoadType) { case ResLoadType.OnlyPrefab: return(this.LoadOnlyPrefab(cell, entityResType)); case ResLoadType.PrefabAndTexture: return(this.PrefabAndTexture(cell, entityResType)); default: string e = string.Format("没有这种加载类型{0}", cell.loadtype); throw new System.Exception(e); } } return(pool); }
public void copyFrom(ResItem rhv) { m_resPackType = rhv.m_resPackType; m_resLoadType = rhv.m_resLoadType; m_path = rhv.m_path; m_pathNoExt = rhv.m_pathNoExt; m_extName = rhv.m_extName; m_resNeedCoroutine = rhv.m_resNeedCoroutine; m_refCountResLoadResultNotify.copyFrom(rhv.refCountResLoadResultNotify); }
public static ResLoadType GetLoadType(ResLoadType loadType) { //如果设置从Resource中加载则忽略打包设置 if (gameLoadType == ResLoadType.Resource) { return(ResLoadType.Resource); } return(loadType); }
private IResLoader LoaderFactory(ResLoadType type) { if (type == ResLoadType.LoadByAssetsBundle) { loader = new ResLoader(); } else { loader = new ResLoaderAB(); } return(loader); }
/// <summary> /// 根据bundleName获取加载路径 /// </summary> /// <param name="bundleName"></param> /// <returns></returns> public static string GetBundlePath(ResourcesConfig config) { bool isLoadByPersistent = RecordManager.GetData(c_HotUpdateRecordName).GetRecord(config.name, false); ResLoadType loadType = ResLoadType.Streaming; //加载路径由 加载根目录 和 相对路径 合并而成 //加载根目录由配置决定 if (isLoadByPersistent) { loadType = ResLoadType.Persistent; } return(PathTool.GetAbsolutePath(loadType, config.path + "." + c_AssetsBundlesExpandName)); }
public List <string> m_pakExtNameList; // 打包的扩展名字列表 public Config() { StreamingAssets = "StreamingAssets/"; UIModelLayer = "UIModel"; m_ip = "192.168.122.253"; m_port = 10002; m_zone = 30; m_webIP = "http://127.0.0.1/UnityServer/"; m_webPort = 80; m_netLogPhp = "/netlog/NetLog.php"; m_pakExtNameList = new List <string>(); m_resLoadType = ResLoadType.eLoadDisc; m_pathLst = new string[(int)ResPathType.eTotal]; m_pathLst[(int)ResPathType.ePathScene] = "Scenes/"; m_pathLst[(int)ResPathType.ePathSceneXml] = "Scenes/Xml/"; m_pathLst[(int)ResPathType.ePathModule] = "Module/"; m_pathLst[(int)ResPathType.ePathComUI] = "UI/"; m_pathLst[(int)ResPathType.ePathComUIScene] = "UIScene/"; m_pathLst[(int)ResPathType.ePathBeingPath] = "Being/"; m_pathLst[(int)ResPathType.ePathAIPath] = "AI/"; m_pathLst[(int)ResPathType.ePathTablePath] = "Table/"; m_pathLst[(int)ResPathType.ePathLangXml] = "Languages/"; m_pathLst[(int)ResPathType.ePathXmlCfg] = "XmlConfig/"; m_pathLst[(int)ResPathType.ePathModel] = "Model/"; m_pathLst[(int)ResPathType.ePathMaterial] = "Model/Materials/"; m_pathLst[(int)ResPathType.ePathBuildImage] = "Image/Build/"; m_pathLst[(int)ResPathType.ePathCardImage] = "Image/Card/"; m_pathLst[(int)ResPathType.ePathWord] = "Word/"; m_pathLst[(int)ResPathType.ePathAudio] = "Sound/"; m_pathLst[(int)ResPathType.ePathAtlas] = "Atlas/"; m_pathLst[(int)ResPathType.ePathSpriteAni] = "Effect/SpriteEffect/"; m_pathLst[(int)ResPathType.ePathSceneAnimatorController] = "Animation/Scene/"; m_pathLst[(int)ResPathType.ePathLuaScript] = "LuaScript/"; m_pathLst[(int)ResPathType.ePathSkillAction] = "SkillAction/"; m_dataPath = Application.dataPath; m_pakExtNameList.Add("prefab"); m_pakExtNameList.Add("png"); m_pakExtNameList.Add("shader"); m_pakExtNameList.Add("unity"); }
public List<string> m_pakExtNameList; // 打包的扩展名字列表 public Config() { StreamingAssets = "StreamingAssets/"; UIModelLayer = "UIModel"; m_ip = "192.168.122.253"; m_port = 10002; m_zone = 30; m_webIP = "http://127.0.0.1/UnityServer/"; m_webPort = 80; m_netLogPhp = "/netlog/NetLog.php"; m_pakExtNameList = new List<string>(); m_resLoadType = ResLoadType.eLoadDisc; m_pathLst = new string[(int)ResPathType.eTotal]; m_pathLst[(int)ResPathType.ePathScene] = "Scenes/"; m_pathLst[(int)ResPathType.ePathSceneXml] = "Scenes/Xml/"; m_pathLst[(int)ResPathType.ePathModule] = "Module/"; m_pathLst[(int)ResPathType.ePathComUI] = "UI/"; m_pathLst[(int)ResPathType.ePathComUIScene] = "UIScene/"; m_pathLst[(int)ResPathType.ePathBeingPath] = "Being/"; m_pathLst[(int)ResPathType.ePathAIPath] = "AI/"; m_pathLst[(int)ResPathType.ePathTablePath] = "Table/"; m_pathLst[(int)ResPathType.ePathLangXml] = "Languages/"; m_pathLst[(int)ResPathType.ePathXmlCfg] = "XmlConfig/"; m_pathLst[(int)ResPathType.ePathModel] = "Model/"; m_pathLst[(int)ResPathType.ePathMaterial] = "Model/Materials/"; m_pathLst[(int)ResPathType.ePathBuildImage] = "Image/Build/"; m_pathLst[(int)ResPathType.ePathCardImage] = "Image/Card/"; m_pathLst[(int)ResPathType.ePathWord] = "Word/"; m_pathLst[(int)ResPathType.ePathAudio] = "Sound/"; m_pathLst[(int)ResPathType.ePathAtlas] = "Atlas/"; m_pathLst[(int)ResPathType.ePathSpriteAni] = "Effect/SpriteEffect/"; m_pathLst[(int)ResPathType.ePathSceneAnimatorController] = "Animation/Scene/"; m_pathLst[(int)ResPathType.ePathLuaScript] = "LuaScript/"; m_pathLst[(int)ResPathType.ePathSkillAction] = "SkillAction/"; m_dataPath = Application.dataPath; m_pakExtNameList.Add("prefab"); m_pakExtNameList.Add("png"); m_pakExtNameList.Add("shader"); m_pakExtNameList.Add("unity"); }
public static void LoadAsync(string name, LoadCallBack callBack) { BundleConfig packData = BundleConfigManager.GetBundleConfig(name); if (packData == null) { return; } ResLoadType loadTypeTmp = GetLoadType(packData.loadType); if (loadTypeTmp == ResLoadType.Resource) { ResourceIOTool.ResourceLoadAsync(packData.path, callBack); } else { AssetsBundleManager.LoadAsync(name, callBack); } }
public static object Load(string name) { BundleConfig packData = BundleConfigManager.GetBundleConfig(name); if (packData == null) { throw new Exception("Load Exception not find " + name); } ResLoadType loadTypeTmp = GetLoadType(packData.loadType); if (loadTypeTmp == ResLoadType.Resource) { return(Resources.Load(packData.path)); } else { return(AssetsBundleManager.Load(name)); } }
public static void modifyLoadParam(string resPath, LoadParam param) { #if PKG_RES_LOAD param.m_origPath = resPath; // 记录原始的资源名字 string retPath = resPath; if ("Module/AutoUpdate.prefab" == resPath) // 自动更新模块更新还没有实现 { param.m_resLoadType = ResLoadType.eStreamingAssets; } else { // 获取包的名字 if (Ctx.m_instance.m_pPakSys.path2PakDic.ContainsKey(resPath)) { retPath = Ctx.m_instance.m_pPakSys.path2PakDic[resPath].m_pakName; } if (param != null) { Ctx.m_instance.m_localFileSys.getAbsPathByRelPath(ref retPath, ref param.m_resLoadType); } else { ResLoadType tmp = ResLoadType.eStreamingAssets; Ctx.m_instance.m_localFileSys.getAbsPathByRelPath(ref retPath, ref tmp); } } param.m_path = retPath; param.m_pakPath = param.m_path; #elif UnPKG_RES_LOAD if (param != null) { param.m_resLoadType = ResLoadType.eStreamingAssets; } param.m_path = resPath; #else param.m_path = resPath; #endif }
public static ResLoadType gameLoadType = ResLoadType.Resource; //默认从resourcePath中读取 public static string GetPath(string localPath, ResLoadType loadType) { StringBuilder path = new StringBuilder(); switch (loadType) { case ResLoadType.Resource: #if UNITY_EDITOR path.Append(Application.dataPath); path.Append("/Resources/"); break; #endif case ResLoadType.Streaming: #if UNITY_EDITOR path.Append(Application.dataPath); path.Append("/StreamingAssets/"); break; #else path.Append(Application.streamingAssetsPath); path.Append("/"); break; #endif case ResLoadType.Persistent: path.Append(Application.persistentDataPath); path.Append("/"); break; case ResLoadType.Catch: path.Append(Application.temporaryCachePath); path.Append("/"); break; default: Debug.LogError("Type Error !" + loadType); break; } path.Append(localPath); return(path.ToString()); }
// 获取当前资源所在的包文件名字 public string getCurResPakPathByResPath(string resPath, LoadParam param) { //Ctx.m_instance.m_shareData.m_resInPakPath = resPath; //return Ctx.m_instance.m_shareData.m_resInPakPath; #if PKG_RES_LOAD string retPath = resPath; if ("Module/AutoUpdate.prefab" == resPath) // 自动更新模块更新还没有实现 { param.m_resLoadType = ResLoadType.eStreamingAssets; } else { // 获取包的名字 if (m_path2PakDic.ContainsKey(resPath)) { retPath = m_path2PakDic[resPath].m_pakName; } if (param != null) { retPath = Ctx.m_instance.m_localFileSys.getAbsPathByRelPath(ref retPath, ref param.m_resLoadType); } else { ResLoadType tmp = ResLoadType.eStreamingAssets; retPath = Ctx.m_instance.m_localFileSys.getAbsPathByRelPath(ref retPath, ref tmp); } } return(retPath); #elif UnPKG_RES_LOAD if (param != null) { param.m_resLoadType = ResLoadType.eStreamingAssets; } return(resPath); #else return(resPath); #endif }
//资源路径数据不依赖任何其他数据 static Dictionary <string, SingleField> GetResourcesConfig() { string dataJson = ""; if (ResourceManager.m_gameLoadType == ResLoadType.Resource) { dataJson = ResourceIOTool.ReadStringByResource( PathTool.GetRelativelyPath(ConfigManager.c_directoryName, c_configFileName, ConfigManager.c_expandName)); } else { ResLoadType type = ResLoadType.Streaming; if (RecordManager.GetData(AssetsBundleManager.c_HotUpdateRecordName).GetRecord(c_configFileName, false)) { type = ResLoadType.Persistent; } dataJson = ResourceIOTool.ReadStringByBundle( PathTool.GetAbsolutePath( type, PathTool.GetRelativelyPath( ConfigManager.c_directoryName, c_configFileName, AssetsBundleManager.c_AssetsBundlesExpandName))); } if (dataJson == "") { throw new Exception("ResourcesConfig not find " + c_configFileName); } else { return(JsonTool.Json2Dictionary <SingleField>(dataJson)); } }
public void Init(ResLoadType type) { loader = LoaderFactory(type); }
/// <summary> /// 组合绝对路径 /// </summary> /// <param name="loadType">资源加载类型</param> /// <param name="relativelyPath">相对路径</param> /// <returns>绝对路径</returns> public static string GetAbsolutePath(ResLoadType loadType, string relativelyPath) { return(GetPath(loadType) + relativelyPath); }
public EquipmentRes(string resName, LoadType loadtype, ResLoadType mResLoadType, Action <UnityEngine.Object> func) : base(resName, loadtype, mResLoadType, func) { loadABType = LoadABType.WholePackage; LoadResByType <EquipmentRes>("/Equipments/" + mResName, loadABType); }
public string getAbsPathByRelPath(ref string relPath, ref ResLoadType loadType) { // 获取版本 string version = Ctx.m_instance.m_versionSys.getFileVer(relPath); string absPath = relPath; if (!string.IsNullOrEmpty(version)) { absPath = UtilLogic.combineVerPath(Path.Combine(Ctx.m_instance.m_localFileSys.getLocalWriteDir(), relPath), version); if (!File.Exists(absPath)) { absPath = Path.Combine(Ctx.m_instance.m_localFileSys.getLocalReadDir(), relPath); if (!File.Exists(absPath)) { absPath = ""; } else { loadType = ResLoadType.eStreamingAssets; } } else { relPath = UtilLogic.combineVerPath(relPath, version); // 在可写目录下,文件名字是有版本号的 loadType = ResLoadType.ePersistentData; } } else { loadType = ResLoadType.eStreamingAssets; } return absPath; }