Skip to content

control-play-mode: Play always saves dirty Scenes before entering Play Mode, rewriting Scene files Unity would keep in memory #3035

Description

@hatayama

Summary

uloop control-play-mode --action Play quietly saves every dirty loaded Scene (and the current Prefab Stage) before entering Play Mode from Edit Mode (ControlPlayModeUseCase.SaveDirtyEditorChangesBeforePlayStart, added in #1756). There is no way to opt out, unlike run-tests --unsaved-changes save|fail|discard, and the response does not say that anything was saved (it only reports Play mode started).

Problem

Unity itself does not block entering Play Mode when Scenes have unsaved changes; it keeps them in memory and restores them after Play Mode ends. The CLI saves them anyway, so the Scene file on disk is rewritten on every CLI Play.

This becomes a problem for Scenes that turn dirty just by being opened (for example, layout groups / CanvasScaler recomputing RectTransform values, or objects that recreate themselves in Edit Mode):

  • Every CLI Play rewrites the Scene file and produces a VCS diff in a Scene the user never edited.
  • If the Scene already has the user's own uncommitted changes, they get mixed with this noise and the user can no longer tell which changes are theirs.
  • An agent that enters Play repeatedly for verification rewrites the file each time without noticing, because the response is silent about the save.

Repro

  1. Open a Scene that becomes dirty on load (or make any change and leave it unsaved).
  2. Run uloop control-play-mode --action Play.
  3. The Scene file on disk is rewritten and git status shows it as modified.

Proposal

  • Add --unsaved-changes to control-play-mode Play, for example:
    • keep: enter Play Mode without saving (Unity's native behavior)
    • save: current behavior
    • fail: stop with the list of unsaved Scenes / Prefab Stage
  • List the saved Scenes / Prefab Stage in the response whenever a save happens, so callers notice the rewrite.
  • Default value is open for discussion. keep matches Unity's native behavior; save stays available for environments where a save dialog would stall the Play start (the motivation of fix: pause-point disconnect no longer leaves Play Mode stuck; quiet-save before CLI Play #1756).

Environment

  • Unity 6000.3.15f1
  • Unity CLI Loop 3.7.1
  • macOS

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions