Unity-Technologies/UnityCsReference · error · ArgumentException
The name is empty
Error message
The name is empty
What it means
AssetImporter.SourceAssetIdentifier(Type type, string name) constructor throws ArgumentException with message 'The name is empty' when name is a non-null empty string. This is a separate guard from the null check (error 35): it catches the case where name is "" specifically, because an empty name cannot identify a sub-asset for remapping. The constructor distinguishes null (ArgumentNullException) from empty (ArgumentException).
Source
Thrown at Editor/Mono/AssetPipeline/AssetImporter.bindings.cs:52
this.type = asset.GetType();
this.name = asset.name;
}
public SourceAssetIdentifier(Type type, string name)
{
if (type == null)
{
throw new ArgumentNullException("type");
}
if (name == null)
{
throw new ArgumentNullException("name");
}
if (string.IsNullOrEmpty(name))
{
throw new ArgumentException("The name is empty", "name");
}
this.type = type;
this.name = name;
}
public Type type;
public string name;
}
[NativeName("AssetPathName")]
public extern string assetPath
{
get;
}
public extern bool importSettingsMissing
{View on GitHub (pinned to 225b0fbdb5)
Solutions
- Check string.IsNullOrEmpty(name) before constructing: if (!string.IsNullOrEmpty(name)) new SourceAssetIdentifier(type, name).
- Filter out blank-named sub-assets when building identifier lists.
- Ensure serialized name fields are populated with meaningful values, not empty strings.
Example fix
// before
var id = new SourceAssetIdentifier(type, assetName);
// after
if (!string.IsNullOrEmpty(assetName))
var id = new SourceAssetIdentifier(type, assetName);
else
Debug.LogWarning($"Skipping SourceAssetIdentifier for type {type.Name}: name is empty"); Defensive patterns
Strategy: validation
Validate before calling
if (!string.IsNullOrEmpty(name))
var id = new AssetImporter.SourceAssetIdentifier(type, name);
else
Debug.LogWarning($"Skipping SourceAssetIdentifier for {type.Name}: name is empty"); Type guard
static bool IsValidIdentifierName(string name) => !string.IsNullOrEmpty(name);
Try / catch
try { var id = new AssetImporter.SourceAssetIdentifier(type, name); }
catch (ArgumentException ex) when (ex.Message == "The name is empty")
{ Debug.LogWarning($"Skipped SourceAssetIdentifier: name was empty"); } Prevention
- Check string.IsNullOrEmpty to cover both null and empty cases
- Ensure sub-asset names are populated with meaningful values
- Filter out blank-named assets when building remap configurations
When it happens
Trigger: Constructing new SourceAssetIdentifier(type, "") where name is an empty string but not null. This happens when deserializing data with present-but-empty name fields, or when asset.name returns empty string for unnamed assets.
Common situations: Loading remap configuration from external sources where name fields exist but are blank. Also occurs with programmatically created assets that have empty names, or after renaming operations that set name to empty before reassignment.
Related errors
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/4affd28c1372c9c3.
Report an issue: GitHub.