{"record":{"id":"379e5aafce1fa01c","repo":"Unity-Technologies/UnityCsReference","slug":"prefabasset","errorCode":null,"errorMessage":"prefabAsset","messagePattern":"prefabAsset","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Prefabs/PrefabUtility.bindings.cs","lineNumber":446,"sourceCode":"        [NativeMethod(\"PrefabUtilityBindings::IsDefaultOverridePropertyPath\", IsFreeFunction = true)]\n        extern internal static bool IsDefaultOverridePropertyPath(string propertyPath);\n\n        [FreeFunction]\n        extern internal static bool CheckIfAddingPrefabWouldResultInCyclicNesting(Object prefabAssetThatIsAddedTo, Object prefabAssetThatWillBeAdded);\n\n        [FreeFunction]\n        extern internal static bool WasCreatedAsPrefabInstancePlaceholderObject(Object componentOrGameObject);\n\n        [FreeFunction]\n        extern internal static void ShowCyclicNestingWarningDialog();\n\n        [NativeMethod(\"PrefabUtilityBindings::GetVariantParentGUID_Internal\", IsFreeFunction = true, ThrowsException = true)]\n        extern internal static string GetVariantParentGUID(EntityId prefabAssetInstanceID);\n\n        internal static string GetVariantParentGUID(GameObject prefabAsset)\n        {\n            if (prefabAsset == null)\n                throw new ArgumentNullException(nameof(prefabAsset));\n            return GetVariantParentGUID(prefabAsset.GetEntityId());\n        }\n\n        [FreeFunction]\n        extern internal static bool IsPathInStreamingAssets(string path);\n\n        [StaticAccessor(\"PrefabUtilityBindings\", StaticAccessorType.DoubleColon)]\n        [NativeMethod(ThrowsException = true)]\n        extern private static bool ApplyObjectOverride([NotNull] Object componentOrGameObject, string assetPath);\n\n        [StaticAccessor(\"PrefabUtilityBindings\", StaticAccessorType.DoubleColon)]\n        [NativeMethod(ThrowsException = true)]\n        extern private static bool ApplyObjectOverrideWithoutUndo([NotNull] Object componentOrGameObject, string assetPath);\n\n        [StaticAccessor(\"PrefabUtilityBindings\", StaticAccessorType.DoubleColon)]\n        [NativeMethod(ThrowsException = true)]\n        extern private static bool ApplyPropertyOverride([NotNull] Object componentOrGameObject, string propertyPath, string assetPath);\n","sourceCodeStart":428,"sourceCodeEnd":464,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Prefabs/PrefabUtility.bindings.cs#L428-L464","documentation":"Thrown by GetVariantParentGUID(GameObject prefabAsset) when the `prefabAsset` argument is null. The method reads the GUID of the prefab a variant was created from, requiring a non-null prefab asset. Uses nameof(prefabAsset) so the parameter name is the message.","triggerScenarios":"Calling PrefabUtility.GetVariantParentGUID(null), or passing a reference resolved from a failed asset lookup, an unassigned serialized field, or a destroyed object.","commonSituations":"Editor inspectors that query variant info but have no asset assigned. Scripts iterating assets where some entries failed to load. Code paths that assume a Selection.activeObject is a prefab when it is null.","solutions":["Pass a non-null prefab asset GameObject.","Null-check prefabAsset before calling and handle the missing case explicitly.","Validate via PrefabUtility.IsPartOfPrefabAsset when you also need to ensure it is a prefab."],"exampleFix":"// before\nvar guid = PrefabUtility.GetVariantParentGUID(maybeNullAsset);\n\n// after\nif (prefabAsset == null) return string.Empty;\nvar guid = PrefabUtility.GetVariantParentGUID(prefabAsset);","handlingStrategy":"validation","validationCode":"if (prefabAsset == null)\n    return string.Empty; // or throw your own descriptive error","typeGuard":"static bool IsPrefabAssetForVariant(GameObject g) => g != null && PrefabUtility.IsPartOfPrefabAsset(g);","tryCatchPattern":null,"preventionTips":["Null-check prefabAsset before querying variant info.","Resolve prefab assets via AssetDatabase.LoadAssetAtPath and validate the result.","Guard generic editor inspectors that may have no asset assigned."],"tags":["prefab","argument-null","variant","guid"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}