9
9
10
10
namespace GitHub . Unity
11
11
{
12
- [ InitializeOnLoad ]
13
12
internal sealed class ApplicationCache : ScriptableObject
14
13
{
15
- static ApplicationCache ( )
16
- {
17
- cachePath = Application . dataPath + "/../Temp/github_cache.yaml" ;
18
- }
19
-
20
14
private static ApplicationCache instance ;
21
- private static string cachePath ;
22
15
23
16
public static ApplicationCache Instance {
24
17
get {
@@ -35,11 +28,11 @@ private static ApplicationCache CreateInstance()
35
28
return foundInstance ;
36
29
}
37
30
38
- if ( System . IO . File . Exists ( cachePath ) )
31
+ if ( System . IO . File . Exists ( GetCachePath ( ) ) )
39
32
{
40
33
Debug . Log ( "Loading from cache" ) ;
41
34
42
- var objects = UnityEditorInternal . InternalEditorUtility . LoadSerializedFileAndForget ( cachePath ) ;
35
+ var objects = UnityEditorInternal . InternalEditorUtility . LoadSerializedFileAndForget ( GetCachePath ( ) ) ;
43
36
if ( objects . Any ( ) )
44
37
{
45
38
var applicationCache = objects [ 0 ] as ApplicationCache ;
@@ -72,11 +65,18 @@ public void Initialize()
72
65
}
73
66
}
74
67
68
+ private static string GetCachePath ( )
69
+ {
70
+ return Application . dataPath + "/../Temp/github_cache.yaml" ;
71
+ }
72
+
75
73
private void OnDisable ( )
76
74
{
77
75
Debug . Log ( "ApplicationCache Disable" ) ;
78
-
79
- UnityEditorInternal . InternalEditorUtility . SaveToSerializedFileAndForget ( new Object [ ] { Instance } , cachePath , true ) ;
76
+ if ( instance != null )
77
+ {
78
+ UnityEditorInternal . InternalEditorUtility . SaveToSerializedFileAndForget ( new Object [ ] { instance } , GetCachePath ( ) , true ) ;
79
+ }
80
80
}
81
81
}
82
82
@@ -105,6 +105,8 @@ static EntryPoint()
105
105
Logging . LoggerFactory = s => new UnityLogAdapter ( s ) ;
106
106
Logging . Info ( "Initializing GitHub for Unity version " + ApplicationInfo . Version ) ;
107
107
108
+ Logging . Trace ( "ApplicationCache: " + ApplicationCache . Instance . CreatedDate ) ;
109
+
108
110
ServicePointManager . ServerCertificateValidationCallback = ServerCertificateValidationCallback ;
109
111
EditorApplication . update += Initialize ;
110
112
}
0 commit comments