Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 39909ae

Browse files
Cannot call in a static constructor Application.dataPath
1 parent 6d19ff7 commit 39909ae

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/UnityExtension/Assets/Editor/GitHub.Unity/EntryPoint.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,9 @@
99

1010
namespace GitHub.Unity
1111
{
12-
[InitializeOnLoad]
1312
internal sealed class ApplicationCache : ScriptableObject
1413
{
15-
static ApplicationCache()
16-
{
17-
cachePath = Application.dataPath + "/../Temp/github_cache.yaml";
18-
}
19-
2014
private static ApplicationCache instance;
21-
private static string cachePath;
2215

2316
public static ApplicationCache Instance {
2417
get {
@@ -35,11 +28,11 @@ private static ApplicationCache CreateInstance()
3528
return foundInstance;
3629
}
3730

38-
if (System.IO.File.Exists(cachePath))
31+
if (System.IO.File.Exists(GetCachePath()))
3932
{
4033
Debug.Log("Loading from cache");
4134

42-
var objects = UnityEditorInternal.InternalEditorUtility.LoadSerializedFileAndForget(cachePath);
35+
var objects = UnityEditorInternal.InternalEditorUtility.LoadSerializedFileAndForget(GetCachePath());
4336
if (objects.Any())
4437
{
4538
var applicationCache = objects[0] as ApplicationCache;
@@ -72,11 +65,18 @@ public void Initialize()
7265
}
7366
}
7467

68+
private static string GetCachePath()
69+
{
70+
return Application.dataPath + "/../Temp/github_cache.yaml";
71+
}
72+
7573
private void OnDisable()
7674
{
7775
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+
}
8080
}
8181
}
8282

@@ -105,6 +105,8 @@ static EntryPoint()
105105
Logging.LoggerFactory = s => new UnityLogAdapter(s);
106106
Logging.Info("Initializing GitHub for Unity version " + ApplicationInfo.Version);
107107

108+
Logging.Trace("ApplicationCache: " + ApplicationCache.Instance.CreatedDate);
109+
108110
ServicePointManager.ServerCertificateValidationCallback = ServerCertificateValidationCallback;
109111
EditorApplication.update += Initialize;
110112
}

0 commit comments

Comments
 (0)