/*do the UI elements for the ignore list*/ private static void HandleIgnoreListPreferences() { if (ignoreList == null) { ignoreList = ExtensionMethods.LoadIgnoreList(); } EditorGUILayout.LabelField("Ignore list - enter the name of a GameObject to ignore when scanning (case sensitive)"); GUILayout.Space(5); var rect = EditorGUILayout.BeginHorizontal(); rect = new Rect(rect.x, rect.y - CellMargin, rect.width, 10 + CellMargin); EditorGUI.DrawRect(new Rect(rect.x, rect.y, rect.width, 55 + CellMargin * 2f), new Color(0.5f, 0.5f, 0.5f, 0.3f));//the drawn rectangle is bigger than the actual rectangle to include the buttons EditorGUI.LabelField(rect, "Use +/- buttons to increase or decrease number of items in ignore list: (" + ignoreList.Count.ToString() + ")"); EditorGUILayout.EndHorizontal(); GUILayout.Space(10); if (GUILayout.Button("+", GUILayout.Width(40))) { ignoreList.Add(new Tuple <string, bool>("", false)); } if (GUILayout.Button("-", GUILayout.Width(40)) && ignoreList.Count > 0) { ignoreList.RemoveAt(ignoreList.Count - 1); dirtyIgnoreList = true; } GUILayout.Space(18); if (ignoreList.Count != 0) { //handle UI and save changes to local ignoreList for (int i = 0; i < ignoreList.Count; i++) { ignoreList[i] = HandleIndividualIgnoreItem(ignoreList[i]); } } //save the inputs, if anything changed if (dirtyIgnoreList) { ExtensionMethods.SaveIgnoreList(ignoreList); dirtyIgnoreList = false; } }
public static bool CheckForNullReferences(Func <NullReference, bool> filter) { var detector = new NullReferenceDetector(); var nullReferences = detector.FindAllNullReferences(filter, ExtensionMethods.LoadIgnoreList(), ExtensionMethods.LoadPrefabList()).ToList(); foreach (var nullReference in nullReferences) { var fieldName = ObjectNames.NicifyVariableName(nullReference.FieldName); var color = ColorFor(nullReference); var message = string.Format("Null reference found in <b>{0}</b> > <b>{1}</b> > <color={2}><b>{3}</b></color>\n", nullReference.GameObjectName, nullReference.ComponentName, color, fieldName); Debug.Log(message, nullReference.GameObject); } return(nullReferences.Any()); }