{"record":{"id":"bbc1ef38ac65e83a","repo":"Unity-Technologies/UnityCsReference","slug":"type-type-name-is-not-a-scriptableobject-or-a-su","errorCode":null,"errorMessage":"Type {type.Name} is not a ScriptableObject or a supported settings object type.","messagePattern":"Type (.+?) is not a ScriptableObject or a supported settings object type\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/BuildProfile/BuildProfile.API.cs","lineNumber":67,"sourceCode":"        public T CreateComponent<T>() where T : UnityEngine.Object\n        {\n            var found = GetComponent<T>();\n            if (found != null)\n            {\n                throw new ArgumentException($\"The component {typeof(T).Name} already exists in the build profile {name}.\");\n            }\n\n            var type = typeof(T);\n            if (type.IsSubclassOf(typeof(ScriptableObject)))\n            {\n                var objectToAdd = ScriptableObject.CreateInstance(type);\n                objectToAdd.hideFlags = HideFlags.HideInHierarchy;\n                objectToAdd.name = type.Name;\n                AssetDatabase.AddObjectToAsset(objectToAdd, this);\n                return objectToAdd as T;\n            }\n\n            throw new ArgumentException($\"Type {type.Name} is not a ScriptableObject or a supported settings object type.\");\n        }\n\n        /// <summary>\n        /// Gets a component of type T associated with the build profile, its global fallback,\n        /// or null if the component is not available.\n        /// </summary>\n        public T GetComponent<T>() where T : UnityEngine.Object\n        {\n            if (typeof(T) == typeof(PlayerSettings))\n            {\n                if (m_PlayerSettings != null)\n                    return m_PlayerSettings as T;\n                return s_GlobalPlayerSettings as T;\n            }\n\n            var path = AssetDatabase.GetAssetPath(this);\n            var objectsFound = AssetDatabase.LoadAllAssetsAtPath(path);\n            foreach (var obj in objectsFound)","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/BuildProfile/BuildProfile.API.cs#L49-L85","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\npublic class MySettings { /* plain class */ }\nprofile.CreateComponent<MySettings>();\n\n// after\n[CreateAssetMenu]\npublic class MySettings : ScriptableObject { /* ... */ }\nprofile.CreateComponent<MySettings>();","handlingStrategy":"type-guard","validationCode":"if (!typeof(T).IsSubclassOf(typeof(ScriptableObject))) throw new InvalidOperationException($\"{typeof(T)} must derive from ScriptableObject.\");","typeGuard":"static bool IsSupportedSettingsType<T>() => typeof(T).IsSubclassOf(typeof(ScriptableObject));","tryCatchPattern":null,"preventionTips":["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."],"tags":["unity","buildprofile","type-mismatch","scriptableobject","argumentexception"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}