Exemplo n.º 1
0
    /// <summary>
    /// 1 读取首包,找出忽略文件
    /// </summary>
    /// <param name="ignoreFiles">Ignore files.</param>
    public static bool ReadFirst(Dictionary <string, uint> firstCrcDict, HashSet <string> whiteFileList, HashSet <string> blackFileList)
    {
        string title = "read first crc file list";

        CrcCheck.Clear();
        bool firstExists = false;

        string readPath = Path.Combine(GetFirstOutPath(), CUtils.GetAssetPath(""));

        readPath = Path.Combine(readPath, CUtils.GetRightFileName(Common.CRC32_FILELIST_NAME));
        Debug.Log(readPath);

        whiteFileList.Clear();
        blackFileList.Clear();

        WWW abload = new WWW("file://" + readPath);

        if (string.IsNullOrEmpty(abload.error) && abload.assetBundle != null)
        {
            var       ab = abload.assetBundle;
            TextAsset ta = ab.LoadAllAssets <TextAsset>()[0];
            //ta.text
            Debug.Log(ta);
            string   context = ta.text;
            string[] split   = context.Split('\n');
            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\[""(.+)""\]\s+=\s+(\d+)");
            float j = 1;
            float l = split.Length;
            foreach (var line in split)
            {
                System.Text.RegularExpressions.Match match = regex.Match(line);
                if (match.Success)
                {
                    //Debug.Log(match.Groups[1].Value + " " + match.Groups[2].Value);
                    //					CrcCheck.Add (match.Groups [1].Value, System.Convert.ToUInt32 (match.Groups [2].Value));
                    firstCrcDict.Add(match.Groups[1].Value, System.Convert.ToUInt32(match.Groups[2].Value));
                }
                //Debug.Log(line);
                EditorUtility.DisplayProgressBar(title, "read first crc => " + j.ToString() + "/" + l.ToString(), j / l);
                j++;
            }
            ab.Unload(true);
            firstExists = true;
        }
        else
        {
            Debug.LogWarning(abload.error + "no frist packeage in " + readPath);
        }
        abload.Dispose();


        //读取忽略扩展包
        string        firstStreamingPath = CUtils.realStreamingAssetsPath;
        DirectoryInfo dinfo = new DirectoryInfo(firstStreamingPath);
        var           dircs = dinfo.GetDirectories();

        foreach (var dir in dircs)
        {
            var           u3dList = ExportResources.getAllChildFiles(dir.FullName, @"\.meta$|\.manifest$|\.DS_Store$", null, false);
            List <string> assets  = new List <string>();
            foreach (var s in u3dList)
            {
                string ab = CUtils.GetAssetBundleName(s);
                ab = ab.Replace("\\", "/");
                blackFileList.Add(ab);
                Debug.Log("extends folder:" + ab);
            }
        }

        //从网络读取白名单列表 todo


        EditorUtility.ClearProgressBar();
        return(firstExists);
    }