stride3d/stride · error · NotSupportedException

Cannot change the name of a

Error message

Cannot change the name of a {nameof(SceneRootViewModel)} object.

What it means

SceneRootViewModel represents a scene nested inside another scene; its Name is read-only and derived from the underlying scene asset. Setting it throws NotSupportedException by design because the name belongs to the scene asset, not this placeholder root node.

Solutions

  1. Skip SceneRootViewModel nodes in rename operations or rename the underlying Asset instead.
  2. Check the node type before setting Name and surface the scene-asset name editor for scene roots.
  3. Catch NotSupportedException if a generic rename pipeline cannot exclude scene roots.

Example fix

// before
selectedNode.Name = newName; // throws for scene roots
// after
if (selectedNode is SceneRootViewModel sceneRoot)
    sceneRoot.Asset.Name = newName; // rename the asset
else
    selectedNode.Name = newName;
Defensive patterns

Strategy: type-guard

Validate before calling

if (node is SceneRootViewModel) { renameAsset(node.Asset, newName); return; }

Type guard

static bool SupportsRename(object vm) => vm is not SceneRootViewModel;

Try / catch

try { node.Name = newName; }
catch (NotSupportedException) { ((SceneRootViewModel)node).Asset.Name = newName; }

Prevention

When it happens

Trigger: Assigning SceneRootViewModel.Name (directly or through a property-grid/rename UI bound to Name) on the root node of a child scene.

Common situations: Rename operations applied to all selected hierarchy nodes including scene roots; generic view-model editors that assume Name is writable; scripts that rename nodes during batch operations.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at sources/editor/Stride.Assets.Presentation/AssetEditors/SceneEditor/ViewModels/SceneRootViewModel.cs:69

            scene.Children.CollectionChanged += SceneChildrenCollectionChanged;

            var offsetNode = Editor.NodeContainer.GetNode(scene.Asset)[nameof(scene.Asset.Offset)];
            offsetNodeBinding = new MemberGraphNodeBinding<Vector3>(offsetNode, nameof(Offset), OnPropertyChanging, OnPropertyChanged, Editor.UndoRedoService);

            LoadSettings().Forget();
        }

        [ItemNotNull, NotNull]
        public IReadOnlyObservableList<SceneRootViewModel> ChildScenes => childScenes;

        /// <inheritdoc/>
        public override AbsoluteId Id => new AbsoluteId(Asset.Id, sceneId);

        /// <inheritdoc/>
        public override IEnumerable<EntityViewModel> InnerSubEntities => ChildrenExceptScenes.SelectMany(x => x.InnerSubEntities);

        /// <inheritdoc />
        public override string Name { get => Asset.Name; set => throw new NotSupportedException($"Cannot change the name of a {nameof(SceneRootViewModel)} object."); }

        public Vector3 Offset { get => offsetNodeBinding.Value; set => offsetNodeBinding.Value = value; }

        [CanBeNull]
        public SceneRootViewModel ParentScene => (SceneRootViewModel)Parent;

        [NotNull]
        public SceneViewModel SceneAsset => (SceneViewModel)Asset;

        /// <summary>
        /// Index of the first scene in the <see cref="EntityHierarchyRootViewModel.Children"/> property.
        /// </summary>
        /// <remarks>
        /// Scene are inserted after all entities and folders.
        /// </remarks>
        private int ChildScenesStartingIndex => Children.Count - ChildScenes.Count;

        [NotNull]

View on GitHub (pinned to 96fad776d2)