/// <summary> /// 获取本地资源文件路径 /// </summary> /// <param name="assetBundlName"></param> /// <returns></returns> public static string GetABFilePath(string fileName) { string filePath = GetSandboxABFilePath(fileName); if (MLFileUtil.CheckFileExits(filePath)) { //Debug.Log("Find sandbox ABFile path====" + filePath); return(filePath); } // 获取stream assets 路径的资源不判定文件是否存在 // android不支持文件判定 filePath = GetLocalABFilePath(fileName); #if !UNITY_ANDROID if (MLFileUtil.CheckFileExits(filePath)) { //Debug.Log("Find local ABFile path====" + filePath); return(filePath); } #else //Debugger.Log("Find local ABFile path====" + filePath); return(filePath); #endif return(filePath); }
private static void WriteExcelDatas(object obj) { byte[] datas = SerializerPBClass(obj); string metaName = string.Format("{0}.bytes", obj.GetType().FullName); MLFileUtil.SaveFile(EXCEL_BIN_FILE_PATH, metaName, datas); }
/// <summary> /// 读取本地资源配置数据 /// </summary> public void LoadLocalGameRes() { // 首先读取沙盒目录下资源配置文件 string xmlPath = ABConfiger.GetSandboxFilePath(TableGameRes.FILE_NAME); Debug.Log("Sandbox xml file path====" + xmlPath); if (MLFileUtil.CheckFileExits(xmlPath)) { localTableResConfig = XMLSerializer.Read <TableGameRes>(xmlPath) as TableGameRes; LoadResConfigComplete(); return; } CoroutineManger.Instance.StartCoroutine(LoadLocalGameResAsync()); }
private Texture2D CreateAlphaTexture(Texture2D src, bool alphaHalfSize, string path = null) { if (src == null) { throw new ArgumentNullException("src"); } // create texture var srcPixels = src.GetPixels(); var tarPixels = new Color[srcPixels.Length]; for (int i = 0; i < srcPixels.Length; i++) { float r = srcPixels[i].a; tarPixels[i] = new Color(r, r, r); } Texture2D alphaTex = new Texture2D(src.width, src.height, TextureFormat.RGB24, false); alphaTex.SetPixels(tarPixels); alphaTex.Apply(); // save string srcPath = path; if (string.IsNullOrEmpty(srcPath)) { srcPath = AssetDatabase.GetAssetPath(src); } string saveAssetPath = GetAlphaTexPath(srcPath); var bytes = alphaTex.EncodeToPNG(); MLFileUtil.SaveFile(saveAssetPath, bytes); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); // setting int size = alphaHalfSize ? Mathf.Max(src.width / 2, src.height / 2, 32) : Mathf.Max(src.width, src.height, 32); ReImportAsset(saveAssetPath, size, androidFormat: TextureImporterFormat.ETC_RGB4, iosFormat: TextureImporterFormat.PVRTC_RGB4); return((Texture2D)AssetDatabase.LoadAssetAtPath(saveAssetPath, typeof(Texture2D))); }
private IEnumerator StartDownload(WWWRequest request) { //Debug.Log("url=====" + request.url); request.www = new WWW(request.url); yield return(request.www); while (!request.www.isDone) { yield return(null); } string filePath = ABConfiger.GetSandboxFilePath(path); Debugger.Log("filePath===" + filePath); byte[] datas = request.www.bytes; MLFileUtil.SaveFile(filePath, bundleFullPath, datas); }
private static List <FileInfo> getExcelFiles() { List <FileInfo> files = MLFileUtil.SearchFiles(EXCEL_FILE_PATH, "*.xlsx"); return(files); }