{"record":{"id":"1166987cbea50b62","repo":"Unity-Technologies/UnityCsReference","slug":"no-valid-types-in-required-type-list","errorCode":null,"errorMessage":"No valid types in required type list","messagePattern":"No valid types in required type list","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/EditorGUI.RequiredTypeList.cs","lineNumber":61,"sourceCode":"        public RequiredTypeList(IEnumerable<Type> requiredTypes, SerializedProperty property)\n        {\n            m_Property = property;\n\n            foreach(var type in requiredTypes)\n            {\n                if (type is { IsInterface: true })\n                {\n                    foreach (var implementedType in TypeCache.GetTypesDerivedFrom(type))\n                    {\n                        AddType(implementedType);\n                    }\n                }\n                else\n                {\n                    AddType(type);\n                }\n\n                if (type != null)\n                    m_DisplayTypes.Add(type);\n            }\n\n            if (m_TypeFromProperty != null)\n                m_DisplayTypes.Add(m_TypeFromProperty);\n\n            if (m_DisplayTypes.Count == 0)\n                throw new ArgumentException(\"No valid types in required type list\");\n        }","sourceCodeStart":null,"sourceCodeEnd":null,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/EditorGUIRequiredTypeList.cs#L61","documentation":"Thrown by the internal RequiredTypeList constructor (used by ObjectField/ObjectSelector) when, after processing every input required type plus the type derivable from the SerializedProperty, there are zero displayable types. The list adds a type only if it can resolve a non-null Type from either the explicit arguments or the property's PPtr name; if none resolve, the constructor refuses to build an empty selector.","triggerScenarios":"Calling EditorGUI.ObjectField (or ObjectSelector.Show) with a requiredTypes collection containing only null entries AND a SerializedProperty whose type string does not match any UnityEngine.Object-derived type via the PPtr<...> regex match. Also when a custom property drawer passes an empty or all-null type array.","commonSituations":"Custom PropertyDrawer that calls ObjectField with null types assuming the property will fill them in, but the property references a built-in type whose name the regex cannot extract. Editor scripts building an object picker for a non-serialized pseudo-property. Mismatch between a SerializedProperty.type string and the actual loaded assembly types.","solutions":["Pass at least one concrete, non-null Type (e.g. typeof(UnityEngine.Object) or your ScriptableObject subclass) in the required types list.","Ensure the SerializedProperty passed actually resolves a field info (ScriptAttributeUtility.GetFieldInfoFromProperty succeeds) so m_TypeFromProperty is populated.","If using a built-in type, confirm its PPtr name in the property string matches a TypeCache-discoverable UnityEngine.Object type.","Guard your ObjectField call by validating requiredTypes.Any(t => t != null) before invoking."],"exampleFix":"// before\nEditorGUI.ObjectField(rect, prop, null); // null required types, prop can't resolve\n\n// after\nEditorGUI.ObjectField(rect, prop, typeof(MyScriptableObject));","handlingStrategy":"validation","validationCode":"if (requiredTypes == null || !requiredTypes.Any(t => t != null)) { if (prop == null) { Debug.LogError(\"ObjectField needs a Type or a resolvable property\"); return; } }","typeGuard":"static bool CanBuildRequiredTypeList(IEnumerable<Type> types, SerializedProperty prop) => types != null && types.Any(t => t != null) || (prop != null && ScriptAttributeUtility.GetFieldInfoFromProperty(prop, out _) != null);","tryCatchPattern":null,"preventionTips":["Always pass at least one concrete Type to ObjectField when the property type is uncertain.","Verify SerializedProperty.propertyType resolves to an object reference before relying on type inference.","In custom drawers, prefer the Type-explicit ObjectField overload."],"tags":["csharp","unity-editor","object-field","selector","type-resolution"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}