File tree Expand file tree Collapse file tree 2 files changed +82
-0
lines changed
Assets/Plugins/CandyCoded.GitStatus/Scripts/CustomEditor Expand file tree Collapse file tree 2 files changed +82
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright (c) Scott Doxey. All Rights Reserved. Licensed under the MIT License. See LICENSE in the project root for license information.
2
+
3
+ #if UNITY_EDITOR
4
+ using System . IO ;
5
+ using UnityEditor ;
6
+ using UnityEngine ;
7
+
8
+ namespace CandyCoded . GitStatus
9
+ {
10
+
11
+ [ InitializeOnLoad ]
12
+ public static class FileWatcher
13
+ {
14
+
15
+ public delegate void EventHandler ( ) ;
16
+
17
+ public static event EventHandler UpdateEvent ;
18
+
19
+ private static FileSystemWatcher _fileSystemWatcher ;
20
+
21
+ private static bool _changeRegistered ;
22
+
23
+ static FileWatcher ( )
24
+ {
25
+
26
+ if ( _fileSystemWatcher != null )
27
+ {
28
+
29
+ return ;
30
+
31
+ }
32
+
33
+ _fileSystemWatcher = new FileSystemWatcher ( Application . dataPath ) ;
34
+
35
+ _fileSystemWatcher . Changed += OnChanged ;
36
+
37
+ _fileSystemWatcher . NotifyFilter = NotifyFilters . LastWrite ;
38
+ _fileSystemWatcher . Filter = "*.*" ;
39
+ _fileSystemWatcher . IncludeSubdirectories = true ;
40
+ _fileSystemWatcher . EnableRaisingEvents = true ;
41
+
42
+ }
43
+
44
+ private static void OnChanged ( object sender , FileSystemEventArgs e )
45
+ {
46
+
47
+ if ( e . FullPath . EndsWith ( ".meta" ) )
48
+ {
49
+
50
+ return ;
51
+
52
+ }
53
+
54
+ if ( ! _changeRegistered )
55
+ {
56
+
57
+ EditorApplication . update += OnAllChanged ;
58
+
59
+ _changeRegistered = true ;
60
+
61
+ }
62
+
63
+ }
64
+
65
+ private static void OnAllChanged ( )
66
+ {
67
+
68
+ UpdateEvent ? . Invoke ( ) ;
69
+
70
+ EditorApplication . update -= OnAllChanged ;
71
+
72
+ _changeRegistered = false ;
73
+
74
+ }
75
+
76
+ }
77
+
78
+ }
79
+ #endif
You can’t perform that action at this time.
0 commit comments