Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Question Unity warning if scene has unsaved changes

Discussion in 'Editor & General Support' started by TheGreenLing, Sep 3, 2023.

  1. TheGreenLing

    TheGreenLing

    Joined:
    Jun 1, 2016
    Posts:
    8
    Does unity currently have a feature to warn you if changes are made to the scene but not yet saved?

    A few times I have made changed to the scene and closed unity only to realize seconds later that I didn't save those changes.

    Is there an option somewhere to trigger this?

    Even an option to ask anytime I close the unity editor "are you sure you want to close unity editor", would be enough to trigger my memory and check if I have saved.

    I don't think this should be particularly hard as unity knows when there are unsaved changes (*), so a simple prompt if scene has *, prompt "are you sure?" (Very new to coding so sounds easy, maybe its not)

    Please let me know if this is possible to set in some way, as I can see myself continuing to encounter this mistake many times in the future.
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    8,647
    Unity does give you a pop-up warning when trying to close the editor whilst there's unsaved scene changes.
     
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    12,015
    Yeah, it should already happen. The only way for it to not happen actually, is if you change scenes via editor script.
     
  4. TheGreenLing

    TheGreenLing

    Joined:
    Jun 1, 2016
    Posts:
    8
    Thanks for your reply, I will have to look into why I am not getting the pop-up warning.
     
  5. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    7,263
    It also won't trigger if you have a custom editor script that improperly modifies objects, likely bypassing both the undo system and Unity's serialization (eg object isn't set as dirty).

    Any standard change, like renaming an object in the hierarchy, will dirty the scene and should give you the popup when trying to load another scene or closing unity.
     
    Kurt-Dekker likes this.