- Home /
Save scene event when the user save the scene in the editor
Hello,
Is there an event or something that I could catch in a scriptable object when the user save its scene in the Unity editor?
My monobehaviour contains extra information information (that are not Serializable by Unity) that I need to save. What is the best strategy to do that?
Thank you very much, Regards,
BigBulle
Answer by BigBulle · Mar 20, 2011 at 12:45 PM
I've placed here bellow the answer of my question above. However, I havent use it to save my extra data. I've got to many side issues with the unity internal serializable system. Hence I've finally prefered to change all my design to use this unity internal serializable system instead.
But if someone wants to detect when the user save the scene in the editor, here is the way I've found:
private FileSystemWatcher m_SceneFileWatcher;
public void OnEnable() { m_SceneFileWatcher = new FileSystemWatcher(Path.GetFullPath("Assets"), "*.unity"); m_SceneFileWatcher.NotifyFilter = NotifyFilters.LastWrite; m_SceneFileWatcher.EnableRaisingEvents = true; m_SceneFileWatcher.Changed += OnSceneFileWatcher_Changed; } void OnSceneFileWatcher_Changed(object sender, FileSystemEventArgs e) { // Do what you want here }
I'm getting a error CS0246: The type or namespace name `FileSystemWatcher' could not be found. Are you missing a using directive or an assembly reference?
This is really weird since it's a System.dll type. Anyone can commment?
Could you elaborate on the internal serializable system please?