com.andysu.unity 0.1.90 → 0.1.106
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Runtime/AndySU.cs +41 -0
- package/package.json +1 -1
package/Runtime/AndySU.cs
CHANGED
|
@@ -7,6 +7,8 @@ namespace AndySU
|
|
|
7
7
|
{
|
|
8
8
|
public enum ApplyPolicy { Live, Restart, NextStart }
|
|
9
9
|
|
|
10
|
+
public enum UpdateMode { Auto, DownloadOnly, CheckOnly, Off }
|
|
11
|
+
|
|
10
12
|
public static class Updates
|
|
11
13
|
{
|
|
12
14
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
|
@@ -26,6 +28,15 @@ namespace AndySU
|
|
|
26
28
|
static AndroidJavaObject Client() => null;
|
|
27
29
|
#endif
|
|
28
30
|
|
|
31
|
+
// The update client when the host is Host API level 3 or newer, which added setMode/mode.
|
|
32
|
+
// On an older host those methods do not exist, so null means "do nothing".
|
|
33
|
+
static AndroidJavaObject ModeClient()
|
|
34
|
+
{
|
|
35
|
+
var h = HostApi();
|
|
36
|
+
if (h == null || h.Call<int>("apiLevel") < 3) return null;
|
|
37
|
+
return h.Call<AndroidJavaObject>("updates");
|
|
38
|
+
}
|
|
39
|
+
|
|
29
40
|
/// <summary>True when the game runs under an AndySU host.</summary>
|
|
30
41
|
public static bool IsPresent => HostApi() != null;
|
|
31
42
|
|
|
@@ -53,5 +64,35 @@ namespace AndySU
|
|
|
53
64
|
};
|
|
54
65
|
Client()?.Call("setApplyPolicy", v);
|
|
55
66
|
}
|
|
67
|
+
|
|
68
|
+
/// <summary>
|
|
69
|
+
/// How much automatic updating this install performs; null for the mode configured in the
|
|
70
|
+
/// host. Needs Host API level 3: does nothing on an older host.
|
|
71
|
+
/// </summary>
|
|
72
|
+
public static void SetUpdateMode(UpdateMode? m)
|
|
73
|
+
{
|
|
74
|
+
string v = m switch
|
|
75
|
+
{
|
|
76
|
+
UpdateMode.Auto => "auto",
|
|
77
|
+
UpdateMode.DownloadOnly => "download_only",
|
|
78
|
+
UpdateMode.CheckOnly => "check_only",
|
|
79
|
+
UpdateMode.Off => "off",
|
|
80
|
+
_ => null,
|
|
81
|
+
};
|
|
82
|
+
ModeClient()?.Call("setMode", v);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/// <summary>The effective update mode; null without a host or on a host older than API level 3.</summary>
|
|
86
|
+
public static UpdateMode? GetUpdateMode()
|
|
87
|
+
{
|
|
88
|
+
switch (ModeClient()?.Call<string>("mode"))
|
|
89
|
+
{
|
|
90
|
+
case "auto": return UpdateMode.Auto;
|
|
91
|
+
case "download_only": return UpdateMode.DownloadOnly;
|
|
92
|
+
case "check_only": return UpdateMode.CheckOnly;
|
|
93
|
+
case "off": return UpdateMode.Off;
|
|
94
|
+
default: return null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
56
97
|
}
|
|
57
98
|
}
|
package/package.json
CHANGED