Skip to content

save_prefab_stage fails when saving prefab preview scenes #1055

@jacklaplante

Description

@jacklaplante

Summary

manage_prefabs fails to save prefab-stage edits because save_prefab_stage appears to save the prefab preview scene with scene-save APIs instead of writing the prefab asset itself.

Error

Error saving prefab stage: EditorSceneManager.SetActive failed; you can not save a preview scene

Minimal Repro

  1. Open any prefab through manage_prefabs(action="open_prefab_stage", prefab_path="Assets/.../Example.prefab").
  2. Make a simple change inside the prefab stage, such as adding a child GameObject.
  3. Call manage_prefabs(action="save_prefab_stage").
  4. Observe the save failure instead of the prefab asset being persisted.

Likely Root Cause

save_prefab_stage appears to use scene-save APIs on a prefab preview scene. In MCPForUnity/Editor/Tools/Prefabs/ManagePrefabs.cs, the current implementation marks prefabStage.scene dirty and then calls EditorSceneManager.SaveScene(prefabStage.scene), but prefab stages use preview scenes rather than normal savable editor scenes.

The prefab-stage save path likely needs to use the prefab asset workflow instead (for example, saving prefabStage.prefabContentsRoot back to prefabStage.assetPath) and close_prefab_stage(saveBeforeClose: true) should reuse the same path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions