//保存一个文本 public static void WriteTextFile(string path, string content, ResLoadLocation type) { #if UNITY_EDITOR ResourceIOTool.WriteStringByFile(PathTool.GetAbsolutePath(type, path), content); #else #endif }
public static void LoadAssetsManifest() { ResLoadLocation type = ResLoadLocation.Streaming; string path = null; if (RecordManager.GetData(HotUpdateManager.c_HotUpdateRecordName).GetRecord(HotUpdateManager.c_useHotUpdateRecordKey, false)) { Debug.Log("LoadAssetsManifest 读取沙盒路径"); type = ResLoadLocation.Persistent; //更新资源存放在Application.persistentDataPath+"/Resources/"目录下 path = PathTool.GetAssetsBundlePersistentPath() + c_ManifestFileName; } else { Debug.Log("LoadAssetsManifest 读取stream路径"); path = PathTool.GetAbsolutePath(type, c_ManifestFileName); } AssetBundle ab = AssetBundle.LoadFromFile(path); s_manifest = ab.LoadAsset <AssetBundleManifest>("AssetBundleManifest"); ab.Unload(false); InitRelayData(); }
public static string ReadVersionContent() { string dataJson = ""; if (ResourceManager.m_gameLoadType == ResLoadLocation.Resource) { dataJson = ResourceIOTool.ReadStringByResource( c_versionFileName + "." + ConfigManager.c_expandName); } else { ResLoadLocation type = ResLoadLocation.Streaming; if (RecordManager.GetData(c_HotUpdateRecordName).GetRecord(c_useHotUpdateRecordKey, false)) { type = ResLoadLocation.Persistent; } dataJson = ResourceIOTool.ReadStringByFile( PathTool.GetAbsolutePath( type, c_versionFileName + "." + ConfigManager.c_expandName)); } return(dataJson); }
public static string ReadVersionContent() { string dataJson = ""; if (ResourceManager.m_gameLoadType == ResLoadLocation.Resource) { dataJson = ResourceIOTool.ReadStringByResource( c_versionFileName + "." + ConfigManager.c_expandName); } else { ResLoadLocation type = ResLoadLocation.Streaming; if (RecordManager.GetData(c_HotUpdateRecordName).GetRecord(c_useHotUpdateRecordKey, false)) { type = ResLoadLocation.Persistent; string persistentPath = PathTool.GetAssetsBundlePersistentPath() + c_versionFileName; AssetBundle ab = AssetBundle.LoadFromFile(persistentPath); TextAsset text = ab.LoadAsset <TextAsset>(c_versionFileName); dataJson = text.text; ab.Unload(true); } else { AssetBundle ab = AssetBundle.LoadFromFile(PathTool.GetAbsolutePath(type, c_versionFileName.ToLower())); TextAsset text = ab.LoadAsset <TextAsset>(c_versionFileName); dataJson = text.text; ab.Unload(true); } } return(dataJson); }
public static ResLoadLocation m_gameLoadType = ResLoadLocation.Resource; //默认从resourcePath中读取 public static ResLoadLocation GetLoadType(ResLoadLocation loadType) { //如果设置从Resource中加载则忽略打包设置 if (m_gameLoadType == ResLoadLocation.Resource) { return(ResLoadLocation.Resource); } return(loadType); }
static int set_m_gameLoadType(IntPtr L) { try { ResLoadLocation arg0 = (ResLoadLocation)ToLua.CheckObject(L, 2, typeof(ResLoadLocation)); ResourceManager.m_gameLoadType = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/// <summary> /// 根据bundleName获取加载路径 /// </summary> /// <param name="bundleName"></param> /// <returns></returns> static string GetBundlePath(ResourcesConfig config) { bool isLoadByPersistent = RecordManager.GetData(HotUpdateManager.c_HotUpdateRecordName).GetRecord(config.name, "null") == "null" ? false:true; ResLoadLocation loadType = ResLoadLocation.Streaming; //加载路径由 加载根目录 和 相对路径 合并而成 //加载根目录由配置决定 if (isLoadByPersistent) { loadType = ResLoadLocation.Persistent; } return(PathTool.GetAbsolutePath(loadType, config.path + "." + c_AssetsBundlesExpandName)); }
static int GetLoadType(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); ResLoadLocation arg0 = (ResLoadLocation)ToLua.CheckObject(L, 1, typeof(ResLoadLocation)); ResLoadLocation o = ResourceManager.GetLoadType(arg0); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public static void LoadResourceConfig() { #if !UNITY_WEBGL string data = ""; if (ResourceManager.m_gameLoadType == ResLoadLocation.Resource) { data = ResourceIOTool.ReadStringByResource(c_ManifestFileName + "." + DataManager.c_expandName); } else { ResLoadLocation type = ResLoadLocation.Streaming; if (RecordManager.GetData(HotUpdateManager.c_HotUpdateRecordName).GetRecord(c_ManifestFileName, "null") != "null") { Debug.Log("LoadResourceConfig 读取沙盒路径"); type = ResLoadLocation.Persistent; //更新资源存放在Application.persistentDataPath+"/Resources/"目录下 string persistentPath = PathTool.GetAssetsBundlePersistentPath() + c_ManifestFileName.ToLower(); AssetBundle ab = AssetBundle.LoadFromFile(persistentPath); TextAsset text = (TextAsset)ab.mainAsset; data = text.text; } else { Debug.Log("LoadResourceConfig 读取stream路径"); string path = PathTool.GetAbsolutePath(type, c_ManifestFileName.ToLower()); //Debug.Log(path); AssetBundle ab = AssetBundle.LoadFromFile(path); TextAsset text = ab.LoadAsset <TextAsset>(c_ManifestFileName); data = text.text; ab.Unload(true); } } s_config = DataTable.Analysis(data); #else return(WEBGLReadResourceConfigContent()); #endif }
static int WriteTextFile(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); string arg0 = ToLua.CheckString(L, 1); string arg1 = ToLua.CheckString(L, 2); ResLoadLocation arg2 = (ResLoadLocation)ToLua.CheckObject(L, 3, typeof(ResLoadLocation)); ResourceManager.WriteTextFile(arg0, arg1, arg2); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void LoadAssetsManifest() { ResLoadLocation type = ResLoadLocation.Streaming; string path = PathUtils.GetAbsolutePath(type, manifestFileName); if (Application.platform != RuntimePlatform.WindowsEditor) { type = ResLoadLocation.Persistent; path = PathUtils.GetAssetsBundlePersistentPath() + manifestFileName; } AssetBundle ab = AssetBundle.LoadFromFile(path); manifest = ab.LoadAsset <AssetBundleManifest>("AssetBundleManifest"); ab.Unload(false); }
public static string ReadResourceConfigContent() { #if !UNITY_WEBGL string dataJson = ""; if (ResourceManager.m_gameLoadType == ResLoadLocation.Resource) { dataJson = ResourceIOTool.ReadStringByResource( c_ManifestFileName + "." + ConfigManager.c_expandName); } else { ResLoadLocation type = ResLoadLocation.Streaming; if (RecordManager.GetData(HotUpdateManager.c_HotUpdateRecordName).GetRecord(HotUpdateManager.c_useHotUpdateRecordKey, false)) { Debug.Log("读取沙盒路径"); type = ResLoadLocation.Persistent; //更新资源存放在Application.persistentDataPath+"/Resources/"目录下 string persistentPath = PathTool.GetAssetsBundlePersistentPath() + c_ManifestFileName + "." + ConfigManager.c_expandName; dataJson = ResourceIOTool.ReadStringByFile(persistentPath); } else { Debug.Log("读取stream路径"); string path = PathTool.GetAbsolutePath( type, c_ManifestFileName + "." + AssetsBundleManager.c_AssetsBundlesExpandName); AssetBundle ab = AssetBundle.LoadFromFile(PathTool.GetAbsolutePath( type, c_ManifestFileName + "." + AssetsBundleManager.c_AssetsBundlesExpandName)); TextAsset text = (TextAsset)ab.mainAsset; dataJson = text.text; ab.Unload(true); } } return(dataJson); #else return(WEBGLReadResourceConfigContent()); #endif }
public static string GetPath(ResLoadLocation loadType) { StringBuilder path = new StringBuilder(); switch (loadType) { case ResLoadLocation.Resource: #if UNITY_EDITOR path.Append(Application.dataPath); path.Append("/Resources/"); break; #endif case ResLoadLocation.Streaming: #if UNITY_ANDROID && !UNITY_EDITOR //path.Append("file://"); path.Append(Application.dataPath); path.Append("!assets/"); #else path.Append(Application.streamingAssetsPath); path.Append("/"); #endif break; case ResLoadLocation.Persistent: path.Append(Application.persistentDataPath); path.Append("/"); break; case ResLoadLocation.Catch: path.Append(Application.temporaryCachePath); path.Append("/"); break; case ResLoadLocation.Develop: path.Append(Application.dataPath); //path.Append(ConstPath.c_ResourceParentPath); break; default: Debug.LogError("Type Error !" + loadType); break; } return(path.ToString()); }
/// <summary> /// 根据bundleName获取加载路径 /// </summary> /// <param name="bundleName"></param> /// <returns></returns> static string GetBundlePath(string bundleName) { #if !UNITY_WEBGL bool isLoadByPersistent = RecordManager.GetData(HotUpdateManager.c_HotUpdateRecordName).GetRecord(bundleName, "null") == "null" ? false:true; ResLoadLocation loadType = ResLoadLocation.Streaming; //加载路径由 加载根目录 和 相对路径 合并而成 //加载根目录由配置决定 if (isLoadByPersistent) { loadType = ResLoadLocation.Persistent; return(PathTool.GetAssetsBundlePersistentPath() + bundleName); } else { return(PathTool.GetAbsolutePath(loadType, bundleName)); } #else return(PathTool.GetLoadURL(config.path + "." + c_AssetsBundlesExpandName)); #endif }
public static string GetPath(ResLoadLocation loadType) { StringBuilder path = new StringBuilder(); switch (loadType) { case ResLoadLocation.Resource: #if UNITY_EDITOR path.Append(Application.dataPath); path.Append("/Resources/"); break; #endif case ResLoadLocation.Streaming: #if UNITY_ANDROID && !UNITY_EDITOR path.Append(Application.dataPath ); path.Append("!assets/"); #else path.Append(Application.streamingAssetsPath); path.Append("/"); #endif break; case ResLoadLocation.Persistent: path.Append(Application.persistentDataPath); path.Append("/"); break; case ResLoadLocation.Catch: path.Append(Application.temporaryCachePath); path.Append("/"); break; default: Debug.LogError("Type Error !" + loadType); break; } return path.ToString(); }
public static string ReadResourceConfigContent() { string dataJson = ""; if (ResourceManager.m_gameLoadType == ResLoadLocation.Resource) { dataJson = ResourceIOTool.ReadStringByResource( c_ManifestFileName + "." + ConfigManager.c_expandName); } else { ResLoadLocation type = ResLoadLocation.Streaming; if (RecordManager.GetData(HotUpdateManager.c_HotUpdateRecordName).GetRecord(HotUpdateManager.c_useHotUpdateRecordKey, false)) { type = ResLoadLocation.Persistent; dataJson = ResourceIOTool.ReadStringByFile( PathTool.GetAbsolutePath( type, c_ManifestFileName + "." + ConfigManager.c_expandName)); } else { AssetBundle ab = AssetBundle.LoadFromFile(PathTool.GetAbsolutePath( type, c_ManifestFileName + "." + AssetsBundleManager.c_AssetsBundlesExpandName)); TextAsset text = (TextAsset)ab.mainAsset; dataJson = text.text; ab.Unload(true); } Debug.Log("loadType: " + type); } return(dataJson); }
public static string GetLoadPathBase(AssetsLoadType assetsloadType, string path) { //#if !UNITY_WEBGL bool isLoadByPersistent = RecordManager.GetData(HotUpdateManager.c_HotUpdateRecordName).GetRecord(path, "null") == "null" ? false : true; ResLoadLocation loadType = ResLoadLocation.Streaming; //加载路径由 加载根目录 和 相对路径 合并而成 //加载根目录由配置决定 if (isLoadByPersistent) { loadType = ResLoadLocation.Persistent; return(PathTool.GetAssetsBundlePersistentPath() + path); } else { loadType = ResLoadLocation.Streaming; return(PathTool.GetAbsolutePath(loadType, path)); } //#else // return PathTool.GetLoadURL(config.path + "." + c_AssetsBundlesExpandName); //#endif }
/// <summary> /// 组合绝对路径 /// </summary> /// <param name="loadType">资源加载类型</param> /// <param name="relativelyPath">相对路径</param> /// <returns>绝对路径</returns> public static string GetAbsolutePath(ResLoadLocation loadType, string relativelyPath) { return GetPath(loadType) + relativelyPath; }
/// <summary> /// 组合绝对路径 /// </summary> /// <param name="loadType">资源加载类型</param> /// <param name="relativelyPath">相对路径</param> /// <returns>绝对路径</returns> public static string GetAbsolutePath(ResLoadLocation loadType, string relativelyPath) { return(GetPath(loadType) + relativelyPath); }