コード例 #1
0
 /// <summary>
 /// 检查文件是否存在,检查顺序为Persist然后Stream
 /// </summary>
 /// <param name="dir"></param>
 /// <param name="path"></param>
 /// <param name="pos"></param>
 /// <returns></returns>
 public static bool IsFileExist(string dir, string fileName, out eFileLoaderPosType pos)
 {
     if (UnityPersistFileHelper.IsPersistAssetFileExist(dir, fileName))
     {
         pos = eFileLoaderPosType.PersistAsset;
         return(true);
     }
     if (UnityStreamingFileHelper.IsStreamAssetFileExist(dir, fileName))
     {
         pos = eFileLoaderPosType.StreamAsset;
         return(true);
     }
     pos = eFileLoaderPosType.None;
     return(false);
 }
コード例 #2
0
    public static Stream ReadFileByStream(string dir, string fileName, out eFileLoaderPosType pos, int offset = 0)
    {
        var hasFile = IsFileExist(dir, fileName, out pos);

        if (hasFile)
        {
            if (pos == eFileLoaderPosType.PersistAsset)
            {
                return(UnityPersistFileHelper.ReadPersistAssetFileByStream(dir, fileName, offset));
            }
            if (pos == eFileLoaderPosType.StreamAsset)
            {
                return(UnityStreamingFileHelper.ReadStreamAssetFileByStream(dir, fileName, offset));
            }
        }
        return(null);
    }
コード例 #3
0
    public static byte[] ReadFileAllBytes(string dir, string fileName, out eFileLoaderPosType pos)
    {
        var hasFile = IsFileExist(dir, fileName, out pos);

        if (hasFile)
        {
            if (pos == eFileLoaderPosType.PersistAsset)
            {
                return(UnityPersistFileHelper.ReadPersistAssetFileAllBytes(dir, fileName));
            }
            if (pos == eFileLoaderPosType.StreamAsset)
            {
                return(UnityStreamingFileHelper.ReadStreamAssetFileAllBytes(dir, fileName));
            }
        }
        return(null);
    }
コード例 #4
0
    public static AssetBundleCreateRequest ReadAssetBundleAsync(string dir, string fileName, ulong offset, out eFileLoaderPosType pos, uint crc = 0U)
    {
        var hasFile = IsFileExist(dir, fileName, out pos);

        if (hasFile)
        {
            if (pos == eFileLoaderPosType.PersistAsset)
            {
                return(UnityPersistFileHelper.ReadPersistAssetBundleAsync(dir, fileName, offset, crc));
            }
            if (pos == eFileLoaderPosType.StreamAsset)
            {
                return(UnityStreamingFileHelper.ReadStreamAssetBundleAsync(dir, fileName, offset, crc));
            }
        }
        return(null);
    }