豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
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