private static void ReplaceBuiltInRes()
    {
        float count = dupBuiltInResDic.Count;
        float i     = 0;

        replacedResAssetDic.Clear();
        foreach (var pair in dupBuiltInResDic)
        {
            Object builtInRes = pair.Key;
            EditorUtility.DisplayProgressBar("替换guiid和fileid", "替换guiid和fileid", ++i / count);
            if (!builtInExtraDic.ContainsKey(builtInRes.name))
            {
                Debug.Log("无该资源" + builtInRes.name);
                continue;
            }
            List <string> abNameList = depObjDic [builtInRes];
            bool          isPack     = false;
            foreach (var abName in abNameList)
            {
                string[] assetPaths = AssetDatabase.GetAssetPathsFromAssetBundle(abName);
                foreach (var path in assetPaths)
                {
                    List <Object> assetObjectList = new List <Object> ();
                    if (path.EndsWith(".unity"))
                    {
                        assetObjectList.Add(AssetDatabase.LoadMainAssetAtPath(path));
                    }
                    else
                    {
                        assetObjectList.AddRange(AssetDatabase.LoadAllAssetsAtPath(path));
                    }
                    Object[] deps = EditorUtility.CollectDependencies(assetObjectList.ToArray());
                    if (deps.Contains(builtInRes))
                    {
                        ReplaceGUIAndFileId(builtInRes, path);
                        RecordReplaceAssetPath(builtInRes, path);
                        isPack = true;
                    }
                }
            }
            if (isPack)
            {
                dupBuiltInResDic[builtInRes] = true;
                GUIIDAndFileId ids  = builtInExtraDic [builtInRes.name];
                string         path = AssetDatabase.GUIDToAssetPath(ids.guid);
                dupResList.AddRange(AssetDatabase.LoadAllAssetsAtPath(path));
            }
        }
        EditorUtility.ClearProgressBar();
    }
 private static void ReplaceGUIAndFileId(Object builInRes, string targetAssetPath)
 {
     try{
         long           defaultFileId = builInRes.GetFileID();
         string         defaultGUIId  = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(builInRes));
         GUIIDAndFileId ids           = builtInExtraDic[builInRes.name];
         StreamReader   sr            = new StreamReader(EditorTools.GetWindowsPath(targetAssetPath));
         string         content       = sr.ReadToEnd();
         sr.Close();
         content = content.Replace(defaultGUIId, ids.guid);
         content = content.Replace(defaultFileId.ToString(), ids.fileid.ToString());
         FileStream   fs = new FileStream(EditorTools.GetWindowsPath(targetAssetPath), FileMode.OpenOrCreate);
         StreamWriter sw = new StreamWriter(fs);
         sw.Write(content);
         sw.WriteLine("#修改标记");
         sw.Close();
         fs.Close();
     }catch {
         throw new UnityException("builnt in extrac dic 数据错误");
     }
 }
 private static void ReverReplaceBuiltInRes()
 {
     foreach (var pair in replacedResAssetDic)
     {
         Object         defaultObj     = pair.Key;
         List <string>  replaceAsset   = pair.Value;
         string         defaultObjPath = AssetDatabase.GetAssetPath(defaultObj);
         GUIIDAndFileId ids            = builtInExtraDic [defaultObj.name];
         foreach (var path in replaceAsset)
         {
             string       windowsPath = EditorTools.GetWindowsPath(path);
             StreamReader sr          = new StreamReader(windowsPath);
             string       content     = sr.ReadToEnd();
             sr.Close();
             content = content.Replace("#修改标记", "");
             content = content.Replace(ids.guid, AssetDatabase.AssetPathToGUID(defaultObjPath));
             content = content.Replace(ids.fileid.ToString(), defaultObj.GetFileID().ToString());
             StreamWriter sw = new StreamWriter(windowsPath);
             sw.Write(content);
             sw.Close();
         }
     }
 }