Last active
October 9, 2015 08:41
-
-
Save ngothanhtai/c508bdab51064b7feee0 to your computer and use it in GitHub Desktop.
Detect save change in Editor mode - Unity3D C#
This file contains hidden or 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 System.Collections; | |
using System.IO; | |
namespace TaiNgo | |
{ | |
[ExecuteInEditMode] | |
public class Activator : MonoBehaviour { | |
#if UNITY_EDITOR | |
string currentOpenScene = ""; | |
void OnEnable() | |
{ | |
Debug.Log("OnEnable"); | |
var m_SceneFileWatcher = new FileSystemWatcher(Path.GetFullPath("Assets"), "*.unity"); | |
m_SceneFileWatcher.NotifyFilter = NotifyFilters.LastWrite; | |
m_SceneFileWatcher.EnableRaisingEvents = true; | |
m_SceneFileWatcher.Changed += OnSceneFileWatcher_Changed; | |
currentOpenScene = Path.GetFileNameWithoutExtension(UnityEditor.EditorApplication.currentScene); | |
} | |
void OnSceneFileWatcher_Changed(object sender, FileSystemEventArgs e) | |
{ | |
var sceneName = Path.GetFileNameWithoutExtension(e.FullPath); | |
if(currentOpenScene.ToLower() == sceneName.ToLower()) | |
{ | |
} | |
} | |
#endif | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment