{"record":{"id":"eaca3fddb537c1d0","repo":"Unity-Technologies/UnityCsReference","slug":"the-type-type-fullname-is-not-supported-by-the-o","errorCode":null,"errorMessage":"The type {type.FullName} is not supported by the ObjectFactory.","messagePattern":"The type (.+?) is not supported by the ObjectFactory\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/ObjectFactory.bindings.cs","lineNumber":55,"sourceCode":"        [AutoStaticsCleanupOnCodeReload]\n        public static event Action<Component> componentWasAdded;\n\n        [RequiredByNativeCode]\n        static void InvokeComponentWasAdded(Component component)\n        {\n            if (componentWasAdded != null)\n                componentWasAdded(component);\n        }\n\n        static void CheckTypeValidity(Type type)\n        {\n            if (type.IsAbstract)\n            {\n                throw new ArgumentException(\"Abstract types can't be used in the ObjectFactory : \" + type.FullName);\n            }\n            if (Attribute.GetCustomAttribute(type, typeof(ExcludeFromObjectFactoryAttribute)) != null)\n            {\n                throw new ArgumentException(\"The type \" + type.FullName + \" is not supported by the ObjectFactory.\");\n            }\n        }\n\n        public static T CreateInstance<T>() where T : Object\n        {\n            return (T)CreateInstance(typeof(T));\n        }\n\n        public static Object CreateInstance(Type type)\n        {\n            CheckTypeValidity(type);\n            if (type == typeof(GameObject))\n            {\n                throw new ArgumentException(\"GameObject type must be created using ObjectFactory.CreateGameObject instead : \" + type.FullName);\n            }\n            if (type.IsSubclassOf(typeof(Component)))\n            {\n                throw new ArgumentException(\"Component type must be created using ObjectFactory.AddComponent instead : \" + type.FullName);","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/ObjectFactory.bindings.cs#L37-L73","documentation":"Thrown by ObjectFactory.CheckTypeValidity when the type is decorated with ExcludeFromObjectFactoryAttribute. Such types are explicitly excluded from the factory's creation path (typically created through specialized APIs instead).","triggerScenarios":"Calling ObjectFactory.CreateInstance on a Type marked [ExcludeFromObjectFactory].","commonSituations":"Type is meant to be created only by the engine; user code tries to factory-instantiate it. Code-generation template iterates all types without respecting the attribute.","solutions":["Do not use ObjectFactory for the excluded type — use its dedicated creation API.","Remove ExcludeFromObjectFactoryAttribute if the type should be factory-created (rare; usually intentional).","Skip excluded types when iterating."],"exampleFix":"// before\nObjectFactory.CreateInstance(typeof(ExcludedType));\n// after: use the type's intended creation path, or filter\nif (Attribute.GetCustomAttribute(t, typeof(ExcludeFromObjectFactoryAttribute)) == null)\n    ObjectFactory.CreateInstance(t);","handlingStrategy":"type-guard","validationCode":"if (Attribute.GetCustomAttribute(type, typeof(ExcludeFromObjectFactoryAttribute)) == null)\n    ObjectFactory.CreateInstance(type);","typeGuard":"static bool IsFactorySupported(Type t) =>\n    Attribute.GetCustomAttribute(t, typeof(ExcludeFromObjectFactoryAttribute)) == null;","tryCatchPattern":null,"preventionTips":["Respect ExcludeFromObjectFactoryAttribute in iteration.","Use the type's dedicated creation API when excluded."],"tags":["unity","object-factory","attribute","validation"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}