using UnityEditor; using UnityEngine; using System.Collections.Generic; namespace IntelligentProjectAnalyzer.Editor { // This class registers the settings provider, which is what makes the settings // appear in the Project Settings window. internal static class AnalyzerSettingsProvider { private static SerializedObject _mSettings; [SettingsProvider] public static SettingsProvider CreateAnalyzerSettingsProvider() { var provider = new SettingsProvider("Project/Analyzer Settings", SettingsScope.Project) { label = "Analyzer Settings", guiHandler = GuiDraw, keywords = new HashSet(new[] { "Analyzer", "Dependency", "Roslyn", "System", "Types" }) }; return provider; } private static void GuiDraw(string _) { _mSettings ??= new SerializedObject(AnalyzerSettingsCrud.GetOrCreateSettings()); EditorGUILayout.LabelField("Default System Types", EditorStyles.boldLabel); EditorGUI.BeginDisabledGroup(true); EditorGUILayout.TextField("System"); EditorGUILayout.TextField("UnityEngine"); EditorGUILayout.TextField("UnityEditor"); EditorGUI.EndDisabledGroup(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Custom System Types", EditorStyles.boldLabel); EditorGUILayout.HelpBox("Add additional namespace prefixes to be ignored by the analyzer (e.g., 'MyCompany.CoreLib').", MessageType.Info); EditorGUILayout.PropertyField(_mSettings.FindProperty("mCustomSystemTypes"), new GUIContent("Ignored Namespaces"), true); EditorGUILayout.Space(); EditorGUILayout.LabelField("Custom Analysis Rules", EditorStyles.boldLabel); EditorGUILayout.HelpBox("Choose which type of unity types to analyze.", MessageType.Info); EditorGUILayout.PropertyField(_mSettings.FindProperty("mAnalyzeScripts"), new GUIContent("Analyze Scripts")); EditorGUILayout.PropertyField(_mSettings.FindProperty("mAnalyzePrefabs"), new GUIContent("Analyze Prefabs")); EditorGUILayout.PropertyField(_mSettings.FindProperty("mAnalyzeScriptableObjects"), new GUIContent("Analyze Scriptable Objects")); EditorGUILayout.PropertyField(_mSettings.FindProperty("mAnalyzeMiscellaneous"), new GUIContent("Analyze Other Assets")); if (_mSettings.hasModifiedProperties) { _mSettings.ApplyModifiedProperties(); } } } }