{"record":{"id":"ed6b6f50a981d4b4","repo":"Unity-Technologies/UnityCsReference","slug":"settings","errorCode":null,"errorMessage":"settings","messagePattern":"settings","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Prefabs/PrefabUtility.cs","lineNumber":2289,"sourceCode":"                    throw new InvalidOperationException(string.Format($\"Cannot replace the Prefab instance when it has a missing script. GameObject '{gameObjectsWithInvalidScript[0].name}' has a missing script. Use InteractionMode.AutomatedAction to force the replace.\"));\n            }\n        }\n\n        public static void ReplacePrefabAssetOfPrefabInstances(GameObject[] prefabInstanceRoots, GameObject prefabAssetRoot, InteractionMode mode)\n        {\n            ReplacePrefabAssetOfPrefabInstances(prefabInstanceRoots, prefabAssetRoot, new PrefabReplacingSettings(), mode);\n        }\n\n        public static void ReplacePrefabAssetOfPrefabInstances(GameObject[] prefabInstanceRoots, GameObject prefabAssetRoot, PrefabReplacingSettings settings, InteractionMode mode)\n        {\n            if (prefabInstanceRoots == null)\n                throw new ArgumentNullException(nameof(prefabInstanceRoots));\n\n            if (prefabInstanceRoots.Length == 0)\n                throw new ArgumentException(nameof(prefabInstanceRoots) + \" has no objects\");\n\n            if (settings == null)\n                throw new ArgumentNullException(nameof(settings));\n\n            ThrowIfInvalidAssetForReplacePrefabInstance(prefabAssetRoot, mode);\n            foreach (var go in prefabInstanceRoots)\n                ThrowIfInvalidArgumentsForReplacePrefabInstance(go, prefabAssetRoot, false, mode);\n\n            foreach (var go in prefabInstanceRoots)\n                ReplacePrefabAssetOfPrefabInstance_NoInputValidation(go, prefabAssetRoot, settings, mode);\n\n            EditorUtility.ForceRebuildInspectors();\n        }\n\n        public static void ReplacePrefabAssetOfPrefabInstance(GameObject prefabInstanceRoot, GameObject prefabAssetRoot, InteractionMode mode)\n        {\n            ReplacePrefabAssetOfPrefabInstance(prefabInstanceRoot, prefabAssetRoot, new PrefabReplacingSettings(), mode);\n        }\n\n        public static void ReplacePrefabAssetOfPrefabInstance(GameObject prefabInstanceRoot, GameObject prefabAssetRoot, PrefabReplacingSettings settings, InteractionMode mode)\n        {","sourceCodeStart":2271,"sourceCodeEnd":2307,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Prefabs/PrefabUtility.cs#L2271-L2307","documentation":"Thrown by ReplacePrefabAssetOfPrefabInstances (the overload taking PrefabReplacingSettings) when the settings parameter is null. PrefabReplacingSettings controls how overrides and object references are handled during the batch replace; a null value is not permitted — the simpler overload constructs a default PrefabReplacingSettings internally.","triggerScenarios":"Calling ReplacePrefabAssetOfPrefabInstances(roots, asset, null, mode) — e.g. a settings object that was conditionally created but the condition was false.","commonSituations":"Serialization/deserialization round-trip that produced null. Optional settings parameter in a wrapper method that wasn't defaulted. Code that intended to call the simpler overload but passed null explicitly.","solutions":["Pass new PrefabReplacingSettings() as the default when you don't need custom settings.","Use the 3-argument overload ReplacePrefabAssetOfPrefabInstances(roots, asset, mode) which constructs default settings for you.","Null-check settings and substitute a default before calling."],"exampleFix":"// before\nPrefabUtility.ReplacePrefabAssetOfPrefabInstances(roots, asset, settings, mode);\n// settings could be null\n\n// after\nPrefabUtility.ReplacePrefabAssetOfPrefabInstances(roots, asset, settings ?? new PrefabReplacingSettings(), mode);","handlingStrategy":"validation","validationCode":"var effectiveSettings = settings ?? new PrefabReplacingSettings();\nPrefabUtility.ReplacePrefabAssetOfPrefabInstances(prefabInstanceRoots, prefabAssetRoot, effectiveSettings, mode);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default optional settings parameters to new PrefabReplacingSettings() in wrapper methods.","Use the simpler 3-argument overload when default settings suffice."],"tags":["prefab","argument-null","settings","argument-validation","unity-editor"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}