stride3d/stride · error · ArgumentNullException

gameSettings

Error message

gameSettings

What it means

InitializeSettingsFromGameSettings copies navigation build settings from a GameSettings asset. The library throws ArgumentNullException immediately when the gameSettings argument is null, because there is no meaningful default to copy from a missing settings object.

Solutions

  1. Load or resolve the GameSettings asset before calling InitializeSettingsFromGameSettings and pass the loaded instance
  2. If no custom settings are needed, skip this call and rely on NavigationSettings defaults instead of passing null
  3. Wrap the call in a null check (if (gameSettings != null)) when settings may legitimately be absent

Example fix

// before
navigationSystem.InitializeSettingsFromGameSettings(gameSettings); // gameSettings may be null
// after
if (gameSettings != null)
    navigationSystem.InitializeSettingsFromGameSettings(gameSettings);
Defensive patterns

Strategy: validation

Validate before calling

if (gameSettings == null)
    throw new InvalidOperationException("GameSettings must be loaded before initializing navigation settings");
navigationSystem.InitializeSettingsFromGameSettings(gameSettings);

Type guard

bool hasGameSettings = gameSettings != null;

Try / catch

try
{
    navigationSystem.InitializeSettingsFromGameSettings(gameSettings);
}
catch (ArgumentNullException)
{
    // settings not loaded yet; fall back to defaults
}

Prevention

When it happens

Trigger: Calling InitializeSettingsFromGameSettings(null), typically when GameSettings has not been loaded/assigned before navigation initialization runs.

Common situations: Headless or tool builds where GameSettings assets aren't loaded; custom game-entry code that calls navigation initialization before the settings service provides a GameSettings; refactoring that removed the settings load step.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/55fdc3d365823d16. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Navigation/DynamicNavigationMeshSystem.cs:109

                BuildSettings = ObjectFactoryRegistry.NewInstance<NavigationMeshBuildSettings>();
                IncludedCollisionGroups = CollisionFilterGroupFlags.AllFilter;
                Groups = new List<NavigationMeshGroup>
                {
                    ObjectFactoryRegistry.NewInstance<NavigationMeshGroup>(),
                };
            }

            sceneSystem = Services.GetSafeServiceAs<SceneSystem>();
            scriptSystem = Services.GetSafeServiceAs<ScriptSystem>();
        }

        /// <summary>
        /// Copies the default settings from the <see cref="GameSettings"/> for building navigation
        /// </summary>
        public void InitializeSettingsFromGameSettings(GameSettings gameSettings)
        {
            if (gameSettings == null)
                throw new ArgumentNullException(nameof(gameSettings));

            // Initialize build settings from game settings
            var navigationSettings = gameSettings.GetOrCreateConfiguration<NavigationSettings>();

            InitializeSettingsFromNavigationSettings(navigationSettings);
        }

        /// <inheritdoc />
        public override void Update(GameTime gameTime)
        {
            // This system should load from settings before becoming functional
            if (!Enabled)
                return;

            if (currentSceneInstance != sceneSystem?.SceneInstance)
            {
                // ReSharper disable once PossibleNullReferenceException
                UpdateScene(sceneSystem.SceneInstance);

View on GitHub (pinned to 96fad776d2)