Unity-Technologies/UnityCsReference · error · ArgumentException
The name is empty
Error message
The name is empty
What it means
The third guard in AssetIdentifier(Type, string): once name is non-null it must also be non-empty, because an empty name is a valid C# string but a meaningless key for the importer's remapping tables (it would match nothing or collide with other empty-named entries). The library treats empty as a usage error distinct from null and throws ArgumentException so callers can tell the two mistakes apart.
Source
Thrown at Editor/Mono/AssetPipeline/SpeedTree/SpeedTreeImporterSettings.cs:164
this.type = asset.GetType().ToString();
this.name = asset.name;
}
public AssetIdentifier(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.ToString();
this.name = name;
}
}
/// <summary>
/// This attribute is used as a callback to set SRP specific properties from the importer.
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class MaterialSettingsCallbackAttribute : Attribute
{
/// <summary>
/// The version of the method.
/// </summary>
public int MethodVersion;
View on GitHub (pinned to 225b0fbdb5)
Solutions
- Guarantee the name is a non-empty string before constructing; validate with !string.IsNullOrEmpty(name).
- If the name comes from a path or filename, sanitize/generate a fallback name (e.g. Path.GetFileNameWithoutExtension) so it can never be empty.
- Reject the offending asset upstream in the import flow with a clear message rather than constructing an invalid identifier.
Example fix
// before
var id = new AssetIdentifier(type, asset.name);
// after
if (string.IsNullOrEmpty(asset.name))
throw new InvalidOperationException("Asset name is empty for " + asset);
var id = new AssetIdentifier(type, asset.name); Defensive patterns
Strategy: validation
Validate before calling
string RequireNonEmptyName(string name) {
if (string.IsNullOrEmpty(name))
throw new InvalidOperationException("Asset name is empty.");
return name;
}
// then: new AssetIdentifier(type, RequireNonEmptyName(asset.name)); Type guard
static bool IsValidIdentifierName(string name) => !string.IsNullOrEmpty(name);
Prevention
- Generate names from a stable source (e.g. Path.GetFileNameWithoutExtension) so they are never empty.
- Reject empty names at the UI/config layer before they reach the pipeline.
- Test the empty-name and null-name cases explicitly in editor tooling.
When it happens
Trigger: Calling new AssetIdentifier(type, ""); passing asset.name where the asset was created but never assigned a meaningful name; trimming user input down to empty.
Common situations: Imported assets with default empty names; editor tooling that lets users clear a name field; scripts that derive names from filenames and hit an edge case producing empty.
Related errors
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/72570d0a4311c019.
Report an issue: GitHub.