示例#1
0
 private void DoCheckAndFix()
 {
     this.PreCheck();
     string[] allAssetPaths = AssetDatabase.GetAllAssetPaths();
     for (int i = 0; i < allAssetPaths.Length; i++)
     {
         string text = allAssetPaths[i];
         UnityEngine.Debug.Log(text);
         if ((string.IsNullOrEmpty(this.selectionPattern) || Regex.IsMatch(text, this.selectionPattern)) && !ResCheckWhiteList.IsInWhiteList(text))
         {
             foreach (KeyValuePair <int, ICheck> keyValuePair in this.checkers)
             {
                 if (this.NeedCheck(new int[]
                 {
                     keyValuePair.Key
                 }))
                 {
                     ICheck value = keyValuePair.Value;
                     if (value.CheckMatch(text) && (Directory.Exists(text) || File.Exists(text)))
                     {
                         if (this.checkMode == CheckMode.CHECK_ONLY)
                         {
                             if (!this.cmdlineMode && EditorUtility.DisplayCancelableProgressBar(text, string.Format("检查中 : {0}/{1} -- {2}", i, allAssetPaths.Length, keyValuePair.Key), (float)i / (float)allAssetPaths.Length))
                             {
                                 EditorUtility.ClearProgressBar();
                                 return;
                             }
                             value.DoCheck(text);
                         }
                         else
                         {
                             if (!this.cmdlineMode && EditorUtility.DisplayCancelableProgressBar(text, string.Format("修理中 : {0}/{1} -- {2}", i, allAssetPaths.Length, keyValuePair.Key), (float)i / (float)allAssetPaths.Length))
                             {
                                 EditorUtility.ClearProgressBar();
                                 return;
                             }
                             value.DoFix(text);
                         }
                     }
                 }
             }
             if (this.NeedCheck(Const.SCENE_CHECK_MASK) && Regex.IsMatch(text, "Assets/(Res|ResTemp)/.*?\\.(unity|UNITY)$"))
             {
                 Scene        scene           = EditorSceneManager.OpenScene(text, 0);
                 GameObject[] rootGameObjects = scene.GetRootGameObjects();
                 foreach (KeyValuePair <int, ICheck> keyValuePair2 in this.checkers)
                 {
                     if (this.NeedCheck(new int[]
                     {
                         keyValuePair2.Key
                     }))
                     {
                         ICheck value2 = keyValuePair2.Value;
                         if (value2.CheckMatch(text))
                         {
                             if (this.checkMode == CheckMode.CHECK_ONLY)
                             {
                                 value2.DoCheckHierarchy(text, rootGameObjects);
                             }
                             else
                             {
                                 value2.DoFixHierarchy(text, rootGameObjects);
                                 EditorSceneManager.MarkSceneDirty(scene);
                             }
                         }
                     }
                 }
                 EditorSceneManager.SaveOpenScenes();
             }
             else if (this.NeedCheck(Const.PREFAB_CHECK_MASK) && Regex.IsMatch(text, "Assets/(Res|ResTemp)/.*?\\.(prefab|PREFAB)$"))
             {
                 GameObject gameObject = AssetDatabase.LoadAssetAtPath <GameObject>(text);
                 if (gameObject)
                 {
                     foreach (KeyValuePair <int, ICheck> keyValuePair3 in this.checkers)
                     {
                         if (this.NeedCheck(new int[]
                         {
                             keyValuePair3.Key
                         }))
                         {
                             ICheck value3 = keyValuePair3.Value;
                             if (value3.CheckMatch(text))
                             {
                                 value3.DoCheckHierarchy(text, new GameObject[]
                                 {
                                     gameObject
                                 });
                             }
                         }
                     }
                 }
             }
         }
     }
     if (!this.cmdlineMode)
     {
         EditorUtility.ClearProgressBar();
     }
     if (this.checkMode == CheckMode.CHECK_FIX)
     {
         this.PostFix();
         return;
     }
     this.PostCheck();
 }