stride3d/stride · error · ArgumentException
game is not of type EntityHierarchyEditorGame
Error message
game is not of type EntityHierarchyEditorGame
What it means
EditorGameNavigationMeshService.Initialize casts the incoming EditorServiceGame to SceneEditorGame; if the cast fails (the game passed is not the entity-hierarchy editor game) an ArgumentException is thrown, since the navigation-mesh service only works with that concrete game type.
Solutions
- Ensure the game passed to editor services is an EntityHierarchyEditorGame (or SceneEditorGame)
- Do not register EditorGameNavigationMeshService in a plain EditorServiceGame host
- Check the service registration/bootstrap code to confirm which game instance is created first
- Verify no custom subclass shadows the expected game type
Example fix
// before var game = new EditorServiceGame(services); navMeshService.Initialize(game); // after var game = new EntityHierarchyEditorGame(services); navMeshService.Initialize(game);
Defensive patterns
Strategy: type-guard
Validate before calling
if (editorGame is SceneEditorGame sceneGame) { /* safe to init navmesh service */ } Type guard
static bool SupportsNavMesh(EditorServiceGame g) => g is SceneEditorGame;
Try / catch
try { await service.Initialize(game); }
catch (ArgumentException ex) { log.Error(ex); /* use a non-navmesh fallback */ } Prevention
- Register navmesh service only with EntityHierarchyEditorGame hosts
- Assert the game type in editor bootstrap before initializing services
- Avoid subclassing EditorServiceGame for scene editing scenarios
When it happens
Trigger: Registering the navigation mesh editor service with an EditorServiceGame instance that is not a SceneEditorGame/EntityHierarchyEditorGame; passing null-adjacent wrong game during editor service initialization.
Common situations: Hosting the navmesh service in a custom editor game class; constructing editor services manually with the wrong game; copy-pasted editor bootstrap code using a base EditorServiceGame.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- IEntityGizmo ' ' must have a constructor with exactly one…
- The given type is not an EntityComponent type
- This operation is not supported.
- The ContentScene has not been initialized yet.
- The service [ ] requires a service of type [ ] to be…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/97e6cca79ec43015.
Report an issue: GitHub.
Appendix: source
Thrown at sources/editor/Stride.Assets.Presentation/AssetEditors/EntityHierarchyEditor/Game/EditorGameNavigationMeshService.cs:176
{
displayGroup.IsVisible = isVisible;
foreach (var component in debugVisuals)
{
ModelComponent modelComponent;
if (component.Value.ModelComponents.TryGetValue(displayGroup.Id, out modelComponent))
{
modelComponent.Enabled = isVisible;
}
}
}
});
}
protected override async Task<bool> Initialize(EditorServiceGame editorGame)
{
if (editorGame == null) throw new ArgumentNullException(nameof(editorGame));
game = editorGame as SceneEditorGame;
if (game == null) throw new ArgumentException($"{nameof(game)} is not of type {nameof(EntityHierarchyEditorGame)}");
sceneEditorController = editor.Controller as SceneEditorController;
if (sceneEditorController == null) throw new ArgumentNullException(nameof(sceneEditorController));
gameSettingsProviderService = editor.ServiceProvider.Get<GameSettingsProviderService>();
gameSettingsProviderService.GameSettingsChanged += GameSettingsProviderServiceOnGameSettingsChanged;
await navigationMeshManager.Initialize();
game.SceneAdded += GameOnSceneAdded;
game.SceneRemoved += GameOnSceneRemoved;
// Add debug entity
rootDebugEntity = new Entity("Navigation debug entity");
game.EditorScene.Entities.Add(rootDebugEntity);
// Handle added/updated navigation meshes so that they can be made visible when this scene is shown
editor.Session.AssetPropertiesChanged += OnAssetPropertiesChanged;
editor.Session.DeletedAssetsChanged += OnDeletedAssetsChanged;View on GitHub (pinned to 96fad776d2)