Exemplo n.º 1
0
    //检查是否有资源被删除,如果原始资源被删除,那么要清空待打包asset和打出来的bundle资源
    public static void CheckDelRes()
    {
        var dic = DetectRepeatRes.GetMD5Dic();

        List <string> resPathList = new List <string>();

        foreach (var p in dic)
        {
            bool b = EditorHelper.BeFileExist(p.Key);

            if (!b)
            {
                //写这里2019.3会报错
                //InvalidOperationException: Collection was modified; enumeration operation may not execute.
                //从记录表中剔除
                //DetectRepeatRes.DelFromMD5Dic (p.Key);

                //DelAssetAndBundle(p.Key);

                resPathList.Add(p.Key);
            }
        }

        for (int i = 0; i < resPathList.Count; i++)
        {
            DetectRepeatRes.DelFromMD5Dic(resPathList[i]);

            DelAssetAndBundle(resPathList[i]);
        }
    }
Exemplo n.º 2
0
    //处理每个要预处理的资源时都检查下,检测当前资源是否需要重新处理 ,返回true需要重新处理
    public static bool CheckNeedUpdate(string fileAbsPath)
    {
        string realModifyPath = DetectRepeatRes.GetRealModifyURL(fileAbsPath);

        bool b = DetectRepeatRes.GetMD5Dic().ContainsKey(realModifyPath);

        if (b)
        {
            //存在
            bool bChanged = DetectRepeatRes.BeFileChanged(fileAbsPath);
            if (bChanged)
            {
                string md5 = DetectRepeatRes.GetMD5(realModifyPath);
                DetectRepeatRes.ModifyMD5Dic(realModifyPath, md5);
                Debug.LogError("更新,存在并修改-------------absPath:" + fileAbsPath + " realModifyPath:" + realModifyPath);
                return(true);
            }
        }
        else
        {
            //不存在
            string md5 = DetectRepeatRes.GetMD5(realModifyPath);
            DetectRepeatRes.Add2MD5Dic(realModifyPath, md5);
            Debug.LogError("更新,不存在------------absPath:" + fileAbsPath + " realModifyPath:" + realModifyPath);
            return(true);
        }

        Debug.LogError("不需要更新------------absPath:" + fileAbsPath + " realModifyPath:" + realModifyPath);
        return(false);
    }