Created
March 17, 2014 04:09
-
-
Save becksebenius/9593857 to your computer and use it in GitHub Desktop.
A small utility which adds a Unity event for preprocessing scene saves.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
using System; | |
using System.Collections.Generic; | |
public class AssetSaveProcess : AssetModificationProcessor | |
{ | |
public static event Action OnSaveCurrentScene; | |
public static string[] OnWillSaveAssets (string[] paths) | |
{ | |
bool savingCurrentScene = false; | |
for(int i = 0; i < paths.Length; i++) | |
{ | |
var path = paths[i]; | |
if(path == EditorApplication.currentScene) | |
{ | |
savingCurrentScene = true; | |
} | |
} | |
if(savingCurrentScene) | |
{ | |
if(OnSaveCurrentScene != null) | |
{ | |
OnSaveCurrentScene(); | |
} | |
} | |
return paths; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment