Unity-Technologies/UnityCsReference · error · ArgumentException
Type {type.Name} is not a ScriptableObject or a supported se
Error message
Type {type.Name} is not a ScriptableObject or a supported settings object type. What it means
Thrown by BuildProfile.CreateComponent<T>() when T is neither a ScriptableObject nor a supported settings object type. The method only knows how to instantiate types that are subclasses of ScriptableObject (via ScriptableObject.CreateInstance), and falls through to this ArgumentException for everything else. Build profile components must be sub-assets, which requires a ScriptableObject-derived type.
Source
Thrown at Editor/Mono/BuildProfile/BuildProfile.API.cs:67
public T CreateComponent<T>() where T : UnityEngine.Object
{
var found = GetComponent<T>();
if (found != null)
{
throw new ArgumentException($"The component {typeof(T).Name} already exists in the build profile {name}.");
}
var type = typeof(T);
if (type.IsSubclassOf(typeof(ScriptableObject)))
{
var objectToAdd = ScriptableObject.CreateInstance(type);
objectToAdd.hideFlags = HideFlags.HideInHierarchy;
objectToAdd.name = type.Name;
AssetDatabase.AddObjectToAsset(objectToAdd, this);
return objectToAdd as T;
}
throw new ArgumentException($"Type {type.Name} is not a ScriptableObject or a supported settings object type.");
}
/// <summary>
/// Gets a component of type T associated with the build profile, its global fallback,
/// or null if the component is not available.
/// </summary>
public T GetComponent<T>() where T : UnityEngine.Object
{
if (typeof(T) == typeof(PlayerSettings))
{
if (m_PlayerSettings != null)
return m_PlayerSettings as T;
return s_GlobalPlayerSettings as T;
}
var path = AssetDatabase.GetAssetPath(this);
var objectsFound = AssetDatabase.LoadAllAssetsAtPath(path);
foreach (var obj in objectsFound)View on GitHub (pinned to 225b0fbdb5)
Solutions
- Make T derive from ScriptableObject (class MySettings : ScriptableObject) so CreateInstance can instantiate it.
- If the object already exists, use AddComponent<T>(existingInstance) instead of CreateComponent<T>() — but it still must be a ScriptableObject sub-asset.
- Verify the generic argument at the call site matches a registered/supported settings type.
Example fix
// before
public class MySettings { /* plain class */ }
profile.CreateComponent<MySettings>();
// after
[CreateAssetMenu]
public class MySettings : ScriptableObject { /* ... */ }
profile.CreateComponent<MySettings>(); Defensive patterns
Strategy: type-guard
Validate before calling
if (!typeof(T).IsSubclassOf(typeof(ScriptableObject))) throw new InvalidOperationException($"{typeof(T)} must derive from ScriptableObject."); Type guard
static bool IsSupportedSettingsType<T>() => typeof(T).IsSubclassOf(typeof(ScriptableObject));
Prevention
- Ensure build profile component types derive from ScriptableObject.
- Add a compile-time or unit-test guard over component types.
- Avoid passing plain classes/MonoBehaviours as profile components.
When it happens
Trigger: Calling CreateComponent<T>() with a T that is a plain class, a MonoBehaviour, a struct, or any type not deriving from ScriptableObject. The IsSubclassOf(typeof(ScriptableObject)) check fails and execution reaches the throw.
Common situations: Passing a regular C# class or a UnityEngine.Object subtype that is not a ScriptableObject; attempting to use a MonoBehaviour-style component as a build profile component; refactoring a type so it no longer inherits ScriptableObject.
Related errors
- The component {typeof(T).Name} already exists in the build p
- The component {typeof(T).Name} is required and cannot be rem
- The object {objectToRemove} (path: {objectToRemovePath}) is
- Cannot create build profile for '{platformName}' (GUID: {pla
- Platform GUID {platformGuid} is not a valid Unity build plat
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/bbc1ef38ac65e83a.
Report an issue: GitHub.