Exemple #1
0
        /// <summary>
        /// Reads the new all text. 同步步读取。优先从persistentDataPath目录取得,再从streamingAssetsPath读书
        /// </summary>
        /// <returns>The new all text.</returns>
        /// <param name="fName">F name.</param>
        public static byte[] readNewAllBytes(string fName)
        {
            try {
                byte[] buff = null;

#if UNITY_WEBGL
                if (!CLCfgBase.self.isEditMode)
                {
                    return(CLPreLoadRes4Webgl.getContent(fName));
                }
#endif
                string fPath = CLPathCfg.persistentDataPath + "/" + fName;
                if (File.Exists(fPath))
                {
                    buff = FileEx.ReadAllBytes(fPath);
                }
                else
                {
                    fPath = Application.streamingAssetsPath + "/" + fName;
                    buff  = FileEx.ReadAllBytes(fPath);
                }
                                #if UNITY_EDITOR
                if (buff == null)
                {
                    Debug.LogError("Get null content == " + fPath);
                }
                                #endif
                return(buff);
            } catch (Exception e) {
                Debug.LogError(e);
                return(null);
            }
        }
Exemple #2
0
 /// <summary>
 /// Reads the new all text. 同步步读取。优先从persistentDataPath目录取得,再从streamingAssetsPath读书
 /// </summary>
 /// <returns>The new all text.</returns>
 /// <param name="fName">F name.</param>
 public static byte[] readNewAllBytes(string fName)
 {
     try {
         byte[] buff  = null;
         string fPath = CLPathCfg.persistentDataPath + "/" + fName;
         if (File.Exists(fPath))
         {
             buff = FileEx.ReadAllBytes(fPath);
         }
         else
         {
             fPath = Application.streamingAssetsPath + "/" + fName;
             buff  = FileEx.ReadAllBytes(fPath);
         }
                         #if UNITY_EDITOR
         if (buff == null)
         {
             Debug.LogError("Get null content == " + fPath);
         }
                         #endif
         return(buff);
     } catch (Exception e) {
         Debug.LogError(e);
         return(null);
     }
 }
Exemple #3
0
 public static byte[] getBytesFromCache(string path)
 {
     if (string.IsNullOrEmpty(path))
     {
         return(null);
     }
     byte[] ret = MapEx.getBytes(FileBytesMap, path);
     if (ret == null)
     {
         ret = FileEx.ReadAllBytes(path);
         FileBytesMap [path] = ret;
     }
     return(ret);
 }