Unity-Technologies/UnityCsReference · error · ArgumentException
No valid types in required type list
Error message
No valid types in required type list
What it means
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.
Source
Thrown at Editor/Mono/EditorGUI.RequiredTypeList.cs:61
public RequiredTypeList(IEnumerable<Type> requiredTypes, SerializedProperty property)
{
m_Property = property;
foreach(var type in requiredTypes)
{
if (type is { IsInterface: true })
{
foreach (var implementedType in TypeCache.GetTypesDerivedFrom(type))
{
AddType(implementedType);
}
}
else
{
AddType(type);
}
if (type != null)
m_DisplayTypes.Add(type);
}
if (m_TypeFromProperty != null)
m_DisplayTypes.Add(m_TypeFromProperty);
if (m_DisplayTypes.Count == 0)
throw new ArgumentException("No valid types in required type list");
}View on GitHub (pinned to 225b0fbdb5)
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.
Example fix
// before EditorGUI.ObjectField(rect, prop, null); // null required types, prop can't resolve // after EditorGUI.ObjectField(rect, prop, typeof(MyScriptableObject));
Defensive patterns
Strategy: validation
Validate before calling
if (requiredTypes == null || !requiredTypes.Any(t => t != null)) { if (prop == null) { Debug.LogError("ObjectField needs a Type or a resolvable property"); return; } } Type guard
static bool CanBuildRequiredTypeList(IEnumerable<Type> types, SerializedProperty prop) => types != null && types.Any(t => t != null) || (prop != null && ScriptAttributeUtility.GetFieldInfoFromProperty(prop, out _) != null);
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- type
- Parameter selected must be of type System.Enum
- Parameter enumValue must be of type System.Enum
- Unsupported enum base type for {0}
- Specified enumType must be System.Enum
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/1166987cbea50b62.
Report an issue: GitHub.