Unity-Technologies/UnityCsReference · error · ArgumentNullException
guid
Error message
guid
What it means
PrefabFamilyPopup.GetPrefabAssetIdentifier computes a Hash128 from a GUID string to use as a cache key for prefab asset info. The method throws ArgumentNullException when the guid parameter is null or empty, since Hash128.Compute on an empty string would produce a meaningless key. This is a precondition guard on an internal static utility method.
Source
Thrown at Editor/Mono/Prefabs/PrefabFamilyPopup.cs:634
}
public static PrefabAssetInfo GetState(string guid)
{
var id = GetPrefabAssetIdentifier(guid);
var cachedPrefabAssetInfo = s_StateCache.GetState(id);
if (cachedPrefabAssetInfo == null)
return null; // not cached yet
var currentPrefabSourceFileHash = AssetDatabase.GetSourceAssetFileHash(guid);
if (currentPrefabSourceFileHash != cachedPrefabAssetInfo.prefabFileHash)
return null; // cache is out of sync
return cachedPrefabAssetInfo;
}
public static Hash128 GetPrefabAssetIdentifier(string guid)
{
if (string.IsNullOrEmpty(guid))
throw new ArgumentNullException(nameof(guid));
return Hash128.Compute(guid);
}
}
class OverridesCounterForPrefabAssets
{
GameObject[] m_PrefabAssetRoots;
List<int> m_OverridesCount;
int m_CurrentAssetIndex;
int m_CurrentStep;
bool m_ChangedCount;
bool m_Debug = false;
public OverridesCounterForPrefabAssets(GameObject[] prefabInstanceRoots)
{
m_PrefabAssetRoots = prefabInstanceRoots;View on GitHub (pinned to 225b0fbdb5)
Solutions
- Check string.IsNullOrEmpty(guid) before calling GetPrefabAssetIdentifier
- Verify the source GameObject is an asset (PrefabUtility.IsPartOfPrefabAsset) before extracting its GUID
- Use AssetDatabase.TryGetAssetPathFromGUID or validate the GUID format before passing it
Example fix
// before
Hash128 id = PrefabFamilyPopup.GetPrefabAssetIdentifier(guid);
// after
if (!string.IsNullOrEmpty(guid))
Hash128 id = PrefabFamilyPopup.GetPrefabAssetIdentifier(guid);
else
return; // or handle the missing-asset case Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(guid))
throw new InvalidOperationException("GUID is null or empty — cannot compute prefab asset identifier.");
// Safe to call GetPrefabAssetIdentifier(guid) Type guard
static bool IsValidGuid(string guid) => !string.IsNullOrEmpty(guid) && guid.Length == 32;
Try / catch
try { Hash128 id = PrefabFamilyPopup.GetPrefabAssetIdentifier(guid); }
catch (ArgumentNullException ex) when (ex.ParamName == "guid")
{ Debug.LogError("GUID is null or empty."); } Prevention
- Always null-check and empty-check GUID strings before passing to identifier methods
- Validate the source asset path resolved to a non-empty GUID via AssetDatabase.AssetPathToGUID
- Use a helper method to guard all GUID-dependent calls
When it happens
Trigger: Calling PrefabFamilyPopup.GetPrefabAssetIdentifier(null) or GetPrefabAssetIdentifier("") directly. Passing a GUID obtained from AssetDatabase.AssetPathToGUID on a path that returned an empty string (e.g., for a scene object that is not an asset).
Common situations: Code that derives a GUID from an asset path but doesn't check whether the path resolved to a valid asset. Scene objects passed to asset-guid lookup functions. Programmatically constructed objects that have no asset backing.
Related errors
- prefabInstance
- The inputObject is null
- Provided GameObject is not a Prefab instance
- Given input object is not a prefab asset
- Object to create variant from has to be a Prefab root
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/1c81de539a51ab18.
Report an issue: GitHub.