public static void ItemCheck(AssetFilter filter) { ICheck checkTypd = (ICheck)Activator.CreateInstance(Type.GetType(filter.CheckTagString)); string[] guids = AssetDatabase.FindAssets(checkTypd.SearchTag, new string[] { filter.path }); float count = guids.Length; float index = 1; List <string> fixList = new List <string>(); foreach (string guid in guids) { string assetPath = AssetDatabase.GUIDToAssetPath(guid); string info = String.Format("{0}/{1} {2}", index, count, assetPath); ICheck _check = (ICheck)Activator.CreateInstance(Type.GetType(filter.CheckTagString)); EditorUtility.DisplayProgressBar(_check.GetType().Name + " Check", info, (float)(index / count)); if (!string.IsNullOrEmpty(assetPath)) { if (!_check.Check(AssetDatabase.GUIDToAssetPath(guid))) { fixList.Add(assetPath); mDictionaryCheck[filter.CheckTagString].Add(_check); if (!_check.CanFix) { Debug.LogError(info + " can not auto fix"); } } } else { Debug.LogError(info + " error" + _check.GetType().Name); } index++; } List <ICheck> list = mDictionaryCheck[filter.CheckTagString]; if (checkTypd.CanFix) { index = 1; count = fixList.Count; foreach (var assetPath in fixList) { string info = String.Format("{0}/{1} {2}", index, count, assetPath); EditorUtility.DisplayProgressBar(checkTypd.GetType().Name + " Fix", info, (float)(index / count)); if (checkTypd.Fix(assetPath)) { Debug.Log(info + " Fixed"); } else { Debug.LogError(info + "auto fix fail"); } index++; } } EditorUtility.ClearProgressBar(); }
private static CheckResult RunCheckInExceptionHandler(ICheck check, IManagementClient managementClient) { try { return check.RunCheck(managementClient); } catch (UnexpectedHttpStatusCodeException exception) { return new CheckResult(true, string.Format("Check '{0}' got unexpected status code {1} {2}", check.GetType().ToString(), exception.StatusCodeNumber, exception.StatusCode )); } catch (Exception exception) { return new CheckResult(true, exception.ToString()); } }
private static CheckResult RunCheckInExceptionHandler(ICheck check, IManagementClient managementClient) { try { return(check.RunCheck(managementClient)); } catch (UnexpectedHttpStatusCodeException exception) { return(new CheckResult(true, string.Format("Check '{0}' got unexpected status code {1} {2}", check.GetType().ToString(), exception.StatusCodeNumber, exception.StatusCode ))); } catch (Exception exception) { return(new CheckResult(true, exception.ToString())); } }