예제 #1
0
        private static void HandlePrefabPreferences()
        {
            if (prefabsList == null)
            {
                prefabsList = ExtensionMethods.LoadPrefabList();
            }

            EditorGUILayout.LabelField("Additional Prefabs to scan (only objects in the scene will be scanned, plus any prefabs which you define here)");
            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 external file list: (" + prefabsList.Count.ToString() + ")");

            EditorGUILayout.EndHorizontal();
            GUILayout.Space(10);

            if (GUILayout.Button("+", GUILayout.Width(40)))
            {
                prefabsList.Add(null);
            }

            if (GUILayout.Button("-", GUILayout.Width(40)) && prefabsList.Count > 0)
            {
                prefabsList.RemoveAt(prefabsList.Count - 1);
                dirtyPrefabsList = true;
            }

            GUILayout.Space(18);

            //handle UI and save changes to local ignoreList
            if (prefabsList.Count > 0)
            {
                for (int i = 0; i < prefabsList.Count; i++)
                {
                    prefabsList[i] = HandleIndividualPrefabItems(prefabsList[i]);
                }
            }

            //save the inputs, if anything changed
            if (dirtyPrefabsList)
            {
                ExtensionMethods.SavePrefabList(prefabsList);
                dirtyPrefabsList = false;
            }
        }
예제 #2
0
        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());
        }