Description
The HasUnsavedChanges
property of the SceneEditorSession
class indicates whether there are any unsaved changes in the current scene being edited. This property is useful for determining if a save operation is necessary before closing the scene or performing other actions that might discard changes.
Usage
Use the HasUnsavedChanges
property to check if the current scene has modifications that have not been saved. This can be particularly useful in scenarios where you want to prompt the user to save changes before closing the editor or switching to another scene.
Example
// Example of checking for unsaved changes in a scene editor session
Editor.SceneEditorSession currentSession = Editor.SceneEditorSession.Active;
if (currentSession.HasUnsavedChanges)
{
// Prompt the user to save changes
// Example: Show a dialog asking if they want to save
// Save the scene if the user agrees
currentSession.Save(false);
}