public static SettingsIssueRecord CheckTagsAndLayers() { var issueBody = new StringBuilder(); /* looking for duplicates in layers */ var layers = new List <string>(InternalEditorUtility.layers); layers.RemoveAll(string.IsNullOrEmpty); var duplicateLayers = CSArrayTools.FindDuplicatesInArray(layers); if (duplicateLayers.Count > 0) { if (issueBody.Length > 0) { issueBody.AppendLine(); } issueBody.Append("Duplicate <b>layer(s)</b>: "); foreach (var duplicate in duplicateLayers) { issueBody.Append('"').Append(duplicate).Append("\", "); } issueBody.Length -= 2; } /* looking for duplicates in sorting layers */ var sortingLayers = new List <string>((string[])CSReflectionTools.GetSortingLayersPropertyInfo().GetValue(null, new object[0])); sortingLayers.RemoveAll(string.IsNullOrEmpty); var duplicateSortingLayers = CSArrayTools.FindDuplicatesInArray(sortingLayers); if (duplicateSortingLayers.Count > 0) { if (issueBody.Length > 0) { issueBody.AppendLine(); } issueBody.Append("Duplicate <b>sorting layer(s)</b>: "); foreach (var duplicate in duplicateSortingLayers) { issueBody.Append('"').Append(duplicate).Append("\", "); } issueBody.Length -= 2; } if (issueBody.Length > 0) { return(SettingsIssueRecord.Create(AssetSettingsKind.TagManager, IssueKind.DuplicateLayers, issueBody.ToString())); } return(null); }
public void TryDetectUnityEventIssues(RecordLocation location, string assetPath, GameObject target, Type componentType, string componentName, int orderIndex, SerializedProperty property) { if (!enabled) { return; } var callbacks = property.FindPropertyRelative("m_PersistentCalls.m_Calls"); if (callbacks == null || callbacks.isArray == false) { Maintainer.ConstructReportWarning("Couldn't find m_PersistentCalls in serialized UnityEvent!", IssuesFinder.ModuleName); return; } IssuesDetector.duplicateComponentDetector.ProcessProperty(callbacks); var callsCount = callbacks.arraySize; for (var i = 0; i < callsCount; i++) { var call = callbacks.GetArrayElementAtIndex(i); var callTarget = call.FindPropertyRelative("m_Target"); if (callTarget == null || callTarget.propertyType != SerializedPropertyType.ObjectReference) { Maintainer.ConstructReportWarning("Couldn't find m_Target in serialized UnityEvent's call!", IssuesFinder.ModuleName); return; } if (IsPropertyHasMissingReference(callTarget)) { AddIssue(location, assetPath, target, componentType, componentName, orderIndex, callTarget.propertyPath); return; } var callTargetObject = callTarget.objectReferenceValue; // no target set if (callTargetObject == null) { continue; } IssuesDetector.duplicateComponentDetector.ProcessProperty(callTarget); var methodName = call.FindPropertyRelative("m_MethodName"); if (methodName == null || methodName.propertyType != SerializedPropertyType.String) { Maintainer.ConstructReportWarning("Couldn't find m_MethodName in serialized UnityEvent's call!", IssuesFinder.ModuleName); return; } IssuesDetector.duplicateComponentDetector.ProcessProperty(methodName); var methodNameValue = methodName.stringValue; // no function set if (string.IsNullOrEmpty(methodNameValue)) { continue; } var arguments = call.FindPropertyRelative("m_Arguments"); if (arguments == null) { Maintainer.ConstructReportWarning("Couldn't find m_Arguments in serialized UnityEvent's call!", IssuesFinder.ModuleName); return; } var objectArgumentAssemblyTypeName = arguments.FindPropertyRelative("m_ObjectArgumentAssemblyTypeName"); if (objectArgumentAssemblyTypeName == null || objectArgumentAssemblyTypeName.propertyType != SerializedPropertyType.String) { Maintainer.ConstructReportWarning("Couldn't find m_ObjectArgumentAssemblyTypeName in m_Arguments!", IssuesFinder.ModuleName); return; } IssuesDetector.duplicateComponentDetector.ProcessProperty(objectArgumentAssemblyTypeName); var mode = call.FindPropertyRelative("m_Mode"); if (mode == null || mode.propertyType != SerializedPropertyType.Enum) { Maintainer.ConstructReportWarning("Couldn't find m_Mode in serialized UnityEvent's call!", IssuesFinder.ModuleName); return; } IssuesDetector.duplicateComponentDetector.ProcessProperty(mode); var modeValue = (PersistentListenerMode)mode.enumValueIndex; var dummyEvent = CSReflectionTools.GetDummyEvent(property); if (dummyEvent == null) { Maintainer.ConstructReportWarning("Couldn't get something from GetDummyEvent!", IssuesFinder.ModuleName); return; } var type = CSReflectionTools.objectType; var stringValue = objectArgumentAssemblyTypeName.stringValue; if (!string.IsNullOrEmpty(stringValue)) { type = Type.GetType(stringValue, false) ?? typeof(UnityEngine.Object); } if (!UnityEventDrawer.IsPersistantListenerValid(dummyEvent, methodNameValue, callTargetObject, modeValue, type)) { AddIssue(location, assetPath, target, componentType, componentName, orderIndex, methodName.propertyPath); return; } } }
public void Draw() { using (new GUILayout.HorizontalScope()) { GUILayout.Space(5); using (new GUILayout.VerticalScope()) { EditorGUI.BeginChangeCheck(); var searchString = searchField.OnGUI( GUILayoutUtility.GetRect(0, 0, 20, 20, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(false)), MaintainerPersonalSettings.References.searchString); if (EditorGUI.EndChangeCheck()) { MaintainerPersonalSettings.References.searchString = searchString; treeView.SetSearchString(searchString); treeView.Reload(); } GetSplitterState(); CSReflectionTools.BeginVerticalSplit(splitterState, new GUILayoutOption[0]); using (new GUILayout.VerticalScope()) { treeView.OnGUI(GUILayoutUtility.GetRect(0, 0, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true))); GUILayout.Space(2f); } using (new GUILayout.VerticalScope()) { GUILayout.Space(2f); using (new GUILayout.VerticalScope(UIHelpers.panelWithoutBackground)) { GUILayout.Label("Exact references", UIHelpers.centeredLabel); GUILayout.Space(1f); } GUILayout.Space(-1f); var selected = treeView.GetSelection(); if (selected != null && selected.Count > 0) { var selectedRow = treeView.GetRow(selected[0]); exactReferencesPanel.Draw(selectedRow); } else { exactReferencesPanel.Draw(null); } } CSReflectionTools.EndVerticalSplit(); SaveSplitterState(); } GUILayout.Space(5); } }