|
Is there some way to get an editor script callback BEFORE the user saves a scene (i.e. just before the scene is written to disk), and AFTER the user loads a scene (i.e. after the scene's objects have been loaded in the editor, but before the user makes any changes)? I want to write a script to validate the scene (and possible modify it) in these two situations, but don't know how to trigger my script.
(comments are locked)
|
|
Not sure, but why not create your own menu item or window that does the save and ask your team to use that. See http://unity3d.com/support/documentation/ScriptReference/EditorApplication.SaveScene.html for ideas. That's always a possibility, but I'd like to not have to change the normal workflow if possible. Otherwise people can always forget, and there's the constant explanations of "Oh, don't use THAT save button, use THIS one. Why? Well, that's just the one you use...". Also it would break things like the normal double-clicking to load behaviour (for scenes) as well as hotkeys (like CTRL-S to save, which would fire the default save, not my 'special save').
Oct 13 '11 at 01:17 PM
AntonStruyk
(comments are locked)
|
|
Performing actions before saving a scene can be done by writing a custom AssetModificationProcessor: Here's an example of how we did it: OnWillSaveAssets will be called every time the user saves the current scene, and you're unable to switch scenes without saving or abandoning all changes. Thus, there ought to be exactly zero or one scene in the paths array. If you want Unity not to save any of the modified assets, you can modify the paths array before returning it. However, changing a scene before it is loaded can't be done this way and I'm interested in how to do that without introducing a special menu item, too...
(comments are locked)
|

Did you ever sort this out? I'm also looking for a solution to this.