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);
    }
Exemplo n.º 3
0
    //输入绝对地址,检测是否是内部资源,如果是地址不变,如果是外部资源,返回对应.meta文件地址
    public static string GetRealModifyURL(string fileAbsPath)
    {
        string filePath = fileAbsPath;

        bool bNativeRes = DetectRepeatRes.BeUnityNativeRes(fileAbsPath);

        if (!bNativeRes)
        {
            filePath = fileAbsPath + ".meta";
        }

        return(filePath);
    }
Exemplo n.º 4
0
    //打包换装模型
    //[MenuItem("RoleEditor/BuildChangeEquipBundle")]
    public static void BuildChangeEquipBundle(string platform)
    {
        EditorHelper.CreateFolder(RoleEditorHelper.ABOutputPath);

        DetectRepeatRes.LoadCheckDic(); //step1
        CheckDelRes();                  //检测是有dic中存在,但工程中不存在的资源

        string manFolderPath = RoleEditorHelper.EDITOR_ROLE_ORIGNAL_RES_PATH + "/man";

        string womenFolderPath = RoleEditorHelper.EDITOR_ROLE_ORIGNAL_RES_PATH + "/women";

        CurBuildSex = "man";

        ProcessChangeEquip(manFolderPath);

        CurBuildSex = "women";

        ProcessChangeEquip(womenFolderPath);

        AssetDatabase.Refresh();

        switch (platform)
        {
        case "win":
            BuildPipeline.BuildAssetBundles(RoleEditorHelper.ABOutputPath, BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.StandaloneWindows64);
            break;

        case "mac":
            BuildPipeline.BuildAssetBundles(RoleEditorHelper.ABOutputPath, BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.StandaloneOSX);
            break;

        case "ios":
            BuildPipeline.BuildAssetBundles(RoleEditorHelper.ABOutputPath, BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.iOS);
            break;

        case "android":
            BuildPipeline.BuildAssetBundles(RoleEditorHelper.ABOutputPath, BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.Android);
            break;
        }



        DetectRepeatRes.SaveCheckDic();
    }
Exemplo n.º 5
0
 public static void ClearMD5Cache()
 {
     DetectRepeatRes.ClearCheckDic();
 }