Unity-Technologies/UnityCsReference · error · ArgumentException
Unknown platform '{0}'
Error message
Unknown platform '{0}' What it means
GetPlatformIndex linearly searches an AssemblyDefinitionPlatform[] for a case-insensitive name match and throws ArgumentException if none is found. It is used to locate a platform when resolving assembly definition references, so an unknown name is treated as an invalid input rather than returning -1.
Source
Thrown at Editor/Mono/Inspector/AssemblyDefinitionImporterInspector.cs:1007
else
data.includePlatforms = dataPlatforms.ToArray();
}
var json = CustomScriptAssemblyData.ToJson(data);
File.WriteAllText(state.path, json);
AssetDatabase.ImportAsset(state.path);
}
static int GetPlatformIndex(AssemblyDefinitionPlatform[] platforms, string name)
{
for (int i = 0; i < platforms.Length; ++i)
{
if (string.Equals(platforms[i].Name, name, System.StringComparison.InvariantCultureIgnoreCase))
return i;
}
throw new System.ArgumentException(string.Format("Unknown platform '{0}'", name), name);
}
void DrawReferenceListElement(Rect rect, int index, bool selected, bool focused)
{
var assemblyDefinitionFile = m_ReferencesList.serializedProperty.GetArrayElementAtIndex(index);
var nameProp = assemblyDefinitionFile.FindPropertyRelative("name");
var assetProp = assemblyDefinitionFile.FindPropertyRelative("asset");
rect.height -= EditorGUIUtility.standardVerticalSpacing;
var label = string.IsNullOrEmpty(nameProp.stringValue) ? L10n.Tr("(Missing Reference)") : nameProp.stringValue;
using (var change = new EditorGUI.ChangeCheckScope())
{
EditorGUI.showMixedValue = assetProp.hasMultipleDifferentValues;
EditorGUI.BeginDisabled(!string.IsNullOrEmpty(nameProp.stringValue) && assetProp.objectReferenceValue == null);
var obj = EditorGUI.ObjectField(rect, EditorGUI.showMixedValue ? GUIContent.Temp("(Multiple Values)") : GUIContent.Temp(label), assetProp.objectReferenceValue, typeof(AssemblyDefinitionAsset), false);
EditorGUI.showMixedValue = false;
EditorGUI.EndDisabled();
View on GitHub (pinned to 225b0fbdb5)
Solutions
- Install the platform module the asmdef references via the Unity Hub/Package Manager.
- Correct the platform name in the asmdef JSON (AssemblyDefinitionImporterInspector) to one present in the registered platforms list.
- Remove the reference to platforms not available in your editor install.
- Confirm the exact Name property expected (the match is case-insensitive against AssemblyDefinitionPlatform.Name).
Example fix
// before: asmdef references "Switch" which is not installed -> ArgumentException // after: install Nintendo Switch module, or edit asmdef to drop the platform
Defensive patterns
Strategy: validation
Validate before calling
// ensure the platform is registered before lookup
bool known = Array.Exists(platforms, p => string.Equals(p.Name, name, StringComparison.InvariantCultureIgnoreCase));
if (!known) throw new InvalidOperationException($"Platform '{name}' is not installed in this editor."); Type guard
static int SafePlatformIndex(AssemblyDefinitionPlatform[] platforms, string name)
{
for (int i = 0; i < platforms.Length; i++)
if (string.Equals(platforms[i].Name, name, StringComparison.InvariantCultureIgnoreCase)) return i;
return -1;
} Prevention
- Install platform modules referenced by asmdefs via Unity Hub before opening the project.
- Validate asmdef platform names against the installed platforms list.
- Edit asmdef JSON to remove platforms absent from your install.
When it happens
Trigger: Passing a platform name string that is not present in the AssemblyDefinitionPlatform[] array provided to the inspector — e.g. a platform not installed/registered in this editor, a typo, or a platform that was removed.
Common situations: An asmdef referencing a platform that is not installed in the current Unity (e.g. a paid/console module absent from this install). A platform name that changed across versions. Manually editing the asmdef JSON with an invalid platform name. Loading a project from a teammate who had extra platform modules installed.
Related errors
- FPS can't be 0.0 or less
- Allowed errors for keyframe reduction cannot be negative.
- For the '{0}' target the 'locationPathName' parameter for Bu
- Cannot create build profile for '{platformName}' (GUID: {pla
- Platform GUID {platformGuid} is not a valid Unity build plat
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/1915a8e45e59feb2.
Report an issue: GitHub.