I have been developing a level editor and I want to add in a feature that detects changes made, so if you try to close out, open a new level, etc, it will prompt you to save any changes. While you may suggest to simply ask you every time you try to close, open a new level, etc, if you want to save, I may need this feature else where in my current project.
So simply put, does anyone know how to detect any and all changes made in a scene, whether that be adding in new gameobjects, changing different options, etc.
Add a ‘I have changed’ event handler then fire this event in the Update of each editable object (e.g. detect that the transform.Position has changed since the last Update - this logic could be placed into a common script used by all objects which are movable for instance). This event can be picked up by your editor class to set an ‘I need updating’ flag. This puts the onus of what needs to be changed on each object rather than the editor itself which should only really be concerned with loading/saving the level and other ‘high level things’.
Event handler:
public interface IEditorMessages: IEventSystemHandler
{
/// <summary>
/// Something was moved
/// </summary>
void ObjectMoved();
}