com.amanotes.gdk 0.2.67 → 0.2.69
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/CHANGELOG.md +39 -0
- package/Editor/AmaGDKEditor.cs +76 -22
- package/Editor/AmaGDKExtra.cs +14 -13
- package/Editor/Extra/GDKAutoUpdateAdapter.cs +14 -1
- package/Editor/Extra/GDKSymbolDefine.cs +372 -0
- package/Editor/{AmaGDKManager.cs.meta → Extra/GDKSymbolDefine.cs.meta} +1 -1
- package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs +35 -3
- package/Extra/AmaGDKInstaller.unitypackage +0 -0
- package/Extra/CheckDiskSpace.unitypackage +0 -0
- package/Extra/Consent.unitypackage +0 -0
- package/Extra/{GoogleCMP.unitypackage.meta → Consent.unitypackage.meta} +1 -1
- package/Extra/ForceUpdate.unitypackage +0 -0
- package/Extra/LegacyGDKUpdateHelper.unitypackage +0 -0
- package/Extra/PostProcessor.unitypackage +0 -0
- package/Packages/AmaGDKConfig.unitypackage +0 -0
- package/Packages/AmaGDKExample.unitypackage +0 -0
- package/Packages/AmaGDKTest.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter.PurchaseConnector.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter.unitypackage +0 -0
- package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
- package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
- package/Packages/IronSourceAdapter.unitypackage +0 -0
- package/Packages/MaxAdNetworkAdapter.unitypackage +0 -0
- package/{Editor/Resources.meta → Packages/MaxAdNetworkAdapter.unitypackage.meta} +1 -2
- package/Packages/RevenueCatAdapter.unitypackage +0 -0
- package/Packages/SqliteAnalyticsAdapter.unitypackage +0 -0
- package/Runtime/Ad/AdExtension.cs +2 -0
- package/Runtime/Ad/AdLogic.cs +79 -69
- package/Runtime/Ad/AdShowContext.cs +1 -0
- package/Runtime/Ad/AmaGDK.Ads.cs +17 -3
- package/Runtime/AmaGDK.Adapters.cs +12 -5
- package/Runtime/AmaGDK.Consent.cs +259 -0
- package/Runtime/AmaGDK.Consent.cs.meta +11 -0
- package/Runtime/AmaGDK.cs +25 -14
- package/Runtime/AudioToolkit/AmaGDK.Audio.Latency.cs +1 -3
- package/Runtime/AudioToolkit/AmaGDK.Audio.cs +56 -24
- package/Runtime/AudioToolkit/Plugins/Android/GDKAudioDeviceDetector.java +1 -1
- package/Runtime/Fps/AmaFPS.cs +0 -1
- package/Runtime/Fps/AmaFPSVisualizer.cs +7 -7
- package/Runtime/Internal/AmaGDK.Internal.AmaGUI.cs +1 -1
- package/Runtime/Internal/GDKGeoLocationcs.cs +3 -1
- package/Runtime/Internal/GDKServerTime.cs +13 -10
- package/package.json +1 -1
- package/Editor/AmaGDKManager.cs +0 -235
- package/Editor/Resources/amasdk-modules.json +0 -31
- package/Editor/Resources/amasdk-modules.json.meta +0 -7
- package/Extra/GoogleCMP.unitypackage +0 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using Amanotes.Core.Internal;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace Amanotes.Core
|
|
6
|
+
{
|
|
7
|
+
public partial class AmaGDK //Consent
|
|
8
|
+
{
|
|
9
|
+
public static partial class Consent //Public
|
|
10
|
+
{
|
|
11
|
+
private static bool _onGoingRequestAllConsents;
|
|
12
|
+
public static void RequestAllConsents(Action onComplete)
|
|
13
|
+
{
|
|
14
|
+
OnAllConsentComplete(onComplete);
|
|
15
|
+
|
|
16
|
+
if (_onGoingRequestAllConsents)
|
|
17
|
+
{
|
|
18
|
+
Logging.LogWarning($"[Consent] RequestAllConsents is called multiple times.");
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_onGoingRequestAllConsents = true;
|
|
23
|
+
#if UNITY_IOS
|
|
24
|
+
ATT.Request(ConsiderCMP);
|
|
25
|
+
#else
|
|
26
|
+
CMP.Request(EndConsent);
|
|
27
|
+
#endif
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public static void OnAllConsentComplete(Action onComplete)
|
|
31
|
+
{
|
|
32
|
+
if (allConsentChecked)
|
|
33
|
+
{
|
|
34
|
+
onComplete?.Invoke();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
_onConsentComplete -= onComplete;
|
|
39
|
+
_onConsentComplete += onComplete;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public static partial class Consent //ATT
|
|
44
|
+
{
|
|
45
|
+
public static class ATT
|
|
46
|
+
{
|
|
47
|
+
public static bool IsAllowed
|
|
48
|
+
{
|
|
49
|
+
get
|
|
50
|
+
{
|
|
51
|
+
if (checkedATT) return allowedATT;
|
|
52
|
+
Logging.LogWarning("[Consent] ATT has not completed yet");
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public static void Request(Action<bool> onComplete)
|
|
58
|
+
{
|
|
59
|
+
if (checkedATT)
|
|
60
|
+
{
|
|
61
|
+
onComplete?.Invoke(allowedATT);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
ConsentHook.ATTRequest(isAllowed =>
|
|
66
|
+
{
|
|
67
|
+
data.att = isAllowed ? Status.Allowed : Status.NotAllowed;
|
|
68
|
+
data.SaveJsonToFile();
|
|
69
|
+
onComplete?.Invoke(allowedATT);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public static partial class Consent //CMP
|
|
77
|
+
{
|
|
78
|
+
public static class CMP
|
|
79
|
+
{
|
|
80
|
+
public static bool IsRequired
|
|
81
|
+
{
|
|
82
|
+
get
|
|
83
|
+
{
|
|
84
|
+
if (checkedCMP) return data.cmp >= Status.Allowed;
|
|
85
|
+
|
|
86
|
+
if (!ConsentHook.IsRequiredCMP.HasValue)
|
|
87
|
+
{
|
|
88
|
+
Logging.LogWarningOnce("[Consent] CMP is not available or not ready");
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return ConsentHook.IsRequiredCMP.Value;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public static void Request(Action<bool> onComplete)
|
|
97
|
+
{
|
|
98
|
+
if (checkedCMP)
|
|
99
|
+
{
|
|
100
|
+
onComplete?.Invoke(checkedCMP);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
ConsentHook.TryToShowCMP(successful =>
|
|
105
|
+
{
|
|
106
|
+
if (successful)
|
|
107
|
+
{
|
|
108
|
+
data.cmp = !IsRequired ? Status.NotRequired : Status.Allowed;
|
|
109
|
+
data.SaveJsonToFile();
|
|
110
|
+
}
|
|
111
|
+
onComplete?.Invoke(checkedCMP);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
public static void ForceShowPopUp(Action onComplete)
|
|
116
|
+
{
|
|
117
|
+
OnAllConsentComplete(onComplete);
|
|
118
|
+
ConsentHook.ForceShowCMP(EndConsent);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
public static partial class Consent //Internal
|
|
124
|
+
{
|
|
125
|
+
private static readonly ConsentData data = new ConsentData().LoadJsonFromFile();
|
|
126
|
+
private static Action _onConsentComplete;
|
|
127
|
+
|
|
128
|
+
internal static bool checkedATT => data.att >= Status.Allowed;
|
|
129
|
+
internal static bool allowedATT => data.att == Status.Allowed;
|
|
130
|
+
internal static bool checkedCMP => data.cmp >= Status.NotRequired;
|
|
131
|
+
internal static bool allConsentChecked => checkedATT && checkedCMP;
|
|
132
|
+
|
|
133
|
+
internal enum Status
|
|
134
|
+
{
|
|
135
|
+
None,
|
|
136
|
+
NotRequired,
|
|
137
|
+
Allowed,
|
|
138
|
+
NotAllowed
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
internal static bool InitModule()
|
|
142
|
+
{
|
|
143
|
+
if (allConsentChecked) return true;
|
|
144
|
+
if (!_config.consent.autoGetConsent) return true;
|
|
145
|
+
RequestAllConsents(null);
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
private static void ConsiderCMP(bool needToShowCMP)
|
|
150
|
+
{
|
|
151
|
+
if (checkedCMP)
|
|
152
|
+
{
|
|
153
|
+
EndConsent(true);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (needToShowCMP)
|
|
158
|
+
{
|
|
159
|
+
ConsentHook.TryToShowCMP(EndConsent);
|
|
160
|
+
}
|
|
161
|
+
else
|
|
162
|
+
{
|
|
163
|
+
ConsentHook.SetNotRequiredCMP(EndConsent);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private static void EndConsent(bool isConsentSuccess)
|
|
168
|
+
{
|
|
169
|
+
var tmpAction = _onConsentComplete;
|
|
170
|
+
_onConsentComplete = null;
|
|
171
|
+
tmpAction?.Invoke();
|
|
172
|
+
Logging.Log("[Consent] End consent checking");
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
[Serializable]
|
|
178
|
+
public class ConsentData : IJsonFile
|
|
179
|
+
{
|
|
180
|
+
[SerializeField] internal AmaGDK.Consent.Status att;
|
|
181
|
+
[SerializeField] internal AmaGDK.Consent.Status cmp;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
public static class ConsentHook
|
|
185
|
+
{
|
|
186
|
+
public static bool? IsRequiredCMP;
|
|
187
|
+
|
|
188
|
+
private static Action<Action<bool>> _tryToShowCMP;
|
|
189
|
+
public static Action<Action<bool>> TryToShowCMP
|
|
190
|
+
{
|
|
191
|
+
get
|
|
192
|
+
{
|
|
193
|
+
if (_tryToShowCMP != null) return _tryToShowCMP;
|
|
194
|
+
|
|
195
|
+
Logging.LogWarning("[Consent] ConsentHook.TryToShowCMP is null");
|
|
196
|
+
_tryToShowCMP = callback => callback(false);
|
|
197
|
+
return _tryToShowCMP;
|
|
198
|
+
}
|
|
199
|
+
set => _tryToShowCMP = value;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
private static Action<Action<bool>> _forceShowCMP;
|
|
203
|
+
public static Action<Action<bool>> ForceShowCMP
|
|
204
|
+
{
|
|
205
|
+
get
|
|
206
|
+
{
|
|
207
|
+
if (_forceShowCMP != null) return _forceShowCMP;
|
|
208
|
+
|
|
209
|
+
Logging.LogWarning("[Consent] ConsentHook.ForceShowCMP is null");
|
|
210
|
+
_forceShowCMP = callback => callback(false);
|
|
211
|
+
return _forceShowCMP;
|
|
212
|
+
}
|
|
213
|
+
set => _forceShowCMP = value;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
private static Action<Action<bool>> _setNotRequiredCMP;
|
|
217
|
+
public static Action<Action<bool>> SetNotRequiredCMP
|
|
218
|
+
{
|
|
219
|
+
get
|
|
220
|
+
{
|
|
221
|
+
if (_setNotRequiredCMP != null) return _setNotRequiredCMP;
|
|
222
|
+
|
|
223
|
+
Logging.LogWarning("[Consent] ConsentHook.SetNotRequiredCMP is null");
|
|
224
|
+
_setNotRequiredCMP = callback => callback(false);
|
|
225
|
+
return _setNotRequiredCMP;
|
|
226
|
+
}
|
|
227
|
+
set => _setNotRequiredCMP = value;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
private static Action<Action<bool>> _attRequest;
|
|
231
|
+
public static Action<Action<bool>> ATTRequest
|
|
232
|
+
{
|
|
233
|
+
get
|
|
234
|
+
{
|
|
235
|
+
if (_attRequest != null) return _attRequest;
|
|
236
|
+
|
|
237
|
+
Logging.LogWarning("[Consent] ConsentHook.ATTRequest is null");
|
|
238
|
+
_attRequest = callback => callback(false);
|
|
239
|
+
return _attRequest;
|
|
240
|
+
}
|
|
241
|
+
set => _attRequest = value;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
namespace Amanotes.Core.Internal
|
|
247
|
+
{
|
|
248
|
+
[Serializable]
|
|
249
|
+
public class ConsentConfig
|
|
250
|
+
{
|
|
251
|
+
[Tooltip("Auto pop-up ATT and CMP form")]
|
|
252
|
+
public bool autoGetConsent = true;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
public partial class ConfigAsset
|
|
256
|
+
{
|
|
257
|
+
[SerializeField] public ConsentConfig consent;
|
|
258
|
+
}
|
|
259
|
+
}
|
package/Runtime/AmaGDK.cs
CHANGED
|
@@ -17,7 +17,7 @@ namespace Amanotes.Core
|
|
|
17
17
|
{
|
|
18
18
|
public partial class AmaGDK : MonoBehaviour
|
|
19
19
|
{
|
|
20
|
-
public const string VERSION = "0.2.
|
|
20
|
+
public const string VERSION = "0.2.69";
|
|
21
21
|
|
|
22
22
|
internal static Status _status = Status.None;
|
|
23
23
|
private static ConfigAsset _config = null;
|
|
@@ -100,11 +100,12 @@ namespace Amanotes.Core
|
|
|
100
100
|
Profiler.BeginSample("AmaGDK.InitModules()");
|
|
101
101
|
{
|
|
102
102
|
User.InitModule();
|
|
103
|
+
Consent.InitModule();
|
|
103
104
|
Analytics.InitModule();
|
|
104
105
|
Ads.InitModule();
|
|
105
106
|
IAP.InitModule();
|
|
106
107
|
RemoteConfig.InitModule();
|
|
107
|
-
Audio.InitModule();
|
|
108
|
+
if (Config.enableAudioModule) Audio.InitModule();
|
|
108
109
|
}
|
|
109
110
|
Profiler.EndSample();
|
|
110
111
|
}
|
|
@@ -124,8 +125,6 @@ namespace Amanotes.Core
|
|
|
124
125
|
|
|
125
126
|
IEnumerator InitAdapters(StringBuilder sb)
|
|
126
127
|
{
|
|
127
|
-
float TIMEOUT = 1;
|
|
128
|
-
|
|
129
128
|
// sort on priority
|
|
130
129
|
List<Adapter2> listAdapters = Adapter2.adapterMap
|
|
131
130
|
.Values.ToList();
|
|
@@ -133,21 +132,32 @@ namespace Amanotes.Core
|
|
|
133
132
|
|
|
134
133
|
foreach (Adapter2 adapter in listAdapters)
|
|
135
134
|
{
|
|
136
|
-
|
|
137
|
-
float startTime = Time.realtimeSinceStartup;
|
|
138
|
-
Profiler.BeginSample($"AmaGDK.adapter.InitSDK-{adapter.adapterId}");
|
|
135
|
+
if (!adapter.enabled)
|
|
139
136
|
{
|
|
140
|
-
adapter.
|
|
137
|
+
Log($"Adapter <{adapter.adapterId} is disabled!");
|
|
138
|
+
continue;
|
|
141
139
|
}
|
|
142
|
-
Profiler.EndSample();
|
|
143
|
-
|
|
144
|
-
yield return GDKUtils.Timeout(TIMEOUT,() => adapter.status != Status.Initialize);
|
|
145
140
|
|
|
146
|
-
|
|
141
|
+
// Log($"Initiating {adapter.adapterId} --> initOrder: {adapter.initOrder} | {adapter.status}");
|
|
142
|
+
var startTime = Time.realtimeSinceStartup;
|
|
143
|
+
Profiler.BeginSample($"AmaGDK.adapter.InitSDK-{adapter.adapterId}");
|
|
144
|
+
adapter.InitSDK();
|
|
145
|
+
Profiler.EndSample();
|
|
146
|
+
|
|
147
|
+
if (adapter.status != Status.Ready)
|
|
147
148
|
{
|
|
148
|
-
|
|
149
|
+
var beginTime = Time.realtimeSinceStartup;
|
|
150
|
+
yield return GDKUtils.Timeout(adapter.Timeout,() => adapter.status != Status.Initialize);
|
|
151
|
+
var endTime = Time.realtimeSinceStartup;
|
|
152
|
+
|
|
153
|
+
if (adapter.status == Status.Initialize)
|
|
154
|
+
{
|
|
155
|
+
LogWarning($"{adapter.adapterId} init time out: {adapter.Timeout:#0.00}");
|
|
156
|
+
} else
|
|
157
|
+
{
|
|
158
|
+
Log($"{adapter.adapterId} init took: {(endTime-beginTime):#0.00} s");
|
|
159
|
+
}
|
|
149
160
|
}
|
|
150
|
-
|
|
151
161
|
dispatcher.Dispatch(Event.ADAPTER_READY, adapter.adapterId);
|
|
152
162
|
sb.AppendLine($"[{(adapter.IsReady ? " OK " : "FAIL")}] {adapter.adapterId} (~ {Time.realtimeSinceStartup - startTime:#0.00}s)");
|
|
153
163
|
|
|
@@ -342,6 +352,7 @@ namespace Amanotes.Core
|
|
|
342
352
|
public const string FIREBASE_REMOTE_CONFIG = "FirebaseRemoteConfig";
|
|
343
353
|
public const string APPSFLYER = "AppsFlyer";
|
|
344
354
|
public const string IRONSOURCE = "IronSource";
|
|
355
|
+
public const string MAX = "Max";
|
|
345
356
|
public const string REVENUECAT = "RevenueCat";
|
|
346
357
|
}
|
|
347
358
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
using System;
|
|
2
|
-
using System.Collections;
|
|
3
|
-
using Amanotes.Core.Internal;
|
|
4
2
|
using UnityEngine;
|
|
5
3
|
|
|
6
4
|
namespace Amanotes.Core
|
|
@@ -75,7 +73,7 @@ namespace Amanotes.Core
|
|
|
75
73
|
return DEFAULT_FOR_SPEAKER;
|
|
76
74
|
}
|
|
77
75
|
|
|
78
|
-
string deviceName =
|
|
76
|
+
string deviceName = currentDevice.name;
|
|
79
77
|
int savedLatency = PlayerPrefs.GetInt(PREF_AUDIO_LATENCY + deviceName, -1);
|
|
80
78
|
|
|
81
79
|
if (savedLatency >= 0)
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
using UnityEngine;
|
|
2
2
|
using System;
|
|
3
|
-
using System.Collections;
|
|
4
|
-
using System.Text;
|
|
5
3
|
using Amanotes.Core.Internal;
|
|
6
4
|
|
|
5
|
+
namespace Amanotes.Core.Internal
|
|
6
|
+
{
|
|
7
|
+
public partial class ConfigAsset
|
|
8
|
+
{
|
|
9
|
+
[SerializeField]
|
|
10
|
+
[Tooltip("Enable to get accurate audio latency & be informed when audio device changed\n\nApi: AmaGDK.Audio.DeviceInfo")]
|
|
11
|
+
public bool enableAudioModule = true;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
7
15
|
namespace Amanotes.Core
|
|
8
16
|
{
|
|
9
17
|
public partial class AmaGDK
|
|
@@ -14,21 +22,38 @@ namespace Amanotes.Core
|
|
|
14
22
|
public const string GDK_AUDIO_INTERRUPT_BEGIN = nameof(GDK_AUDIO_INTERRUPT_BEGIN);
|
|
15
23
|
public const string GDK_AUDIO_INTERRUPT_END = nameof(GDK_AUDIO_INTERRUPT_END);
|
|
16
24
|
}
|
|
17
|
-
|
|
18
|
-
{
|
|
19
|
-
internal AudioDeviceType Type;
|
|
20
|
-
internal string RawType;
|
|
21
|
-
public string Name;
|
|
22
|
-
public int LatencyMs;
|
|
23
|
-
}
|
|
25
|
+
|
|
24
26
|
// Public Usage
|
|
25
|
-
public partial class Audio
|
|
27
|
+
public static partial class Audio
|
|
26
28
|
{
|
|
27
|
-
public
|
|
29
|
+
public class AudioDeviceInfo
|
|
30
|
+
{
|
|
31
|
+
internal AudioDeviceType type;
|
|
32
|
+
internal string rawType;
|
|
33
|
+
public string name;
|
|
34
|
+
public int latencyMs;
|
|
35
|
+
|
|
36
|
+
public override string ToString()
|
|
37
|
+
{
|
|
38
|
+
if (string.IsNullOrEmpty(rawType) || string.IsNullOrEmpty(name)) return base.ToString();
|
|
39
|
+
return $"type: {type.ToString().ToLower()} rawType:{rawType} name:{name}";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private static AudioDeviceInfo _currentDevice;
|
|
44
|
+
|
|
45
|
+
public static AudioDeviceInfo currentDevice
|
|
46
|
+
{
|
|
47
|
+
get => _currentDevice ?? NO_DEVICE;
|
|
48
|
+
private set => _currentDevice = value;
|
|
49
|
+
}
|
|
28
50
|
|
|
29
51
|
private static readonly AudioDeviceInfo NO_DEVICE = new AudioDeviceInfo()
|
|
30
52
|
{
|
|
31
|
-
|
|
53
|
+
type = AudioDeviceType.Unknown,
|
|
54
|
+
rawType = string.Empty,
|
|
55
|
+
name = "NO_DEVICE",
|
|
56
|
+
latencyMs = DEFAULT_FOR_SPEAKER
|
|
32
57
|
};
|
|
33
58
|
|
|
34
59
|
/// <remarks>
|
|
@@ -40,6 +65,8 @@ namespace Amanotes.Core
|
|
|
40
65
|
/// </remarks>
|
|
41
66
|
public static void SetOnAudioDeviceChangeCallback(Action<AudioDeviceInfo> onAudioDeviceChange)
|
|
42
67
|
{
|
|
68
|
+
GDKUtils.ThrowIf(!Config.enableAudioModule, "Audio Module is disabled, Please enable it in the AmaGDKConfig");
|
|
69
|
+
|
|
43
70
|
if (onAudioDeviceChange == null)
|
|
44
71
|
{
|
|
45
72
|
Logging.LogWarning("Cannot add a null callback!");
|
|
@@ -51,6 +78,8 @@ namespace Amanotes.Core
|
|
|
51
78
|
|
|
52
79
|
public static void SetOnAudioInterruptedCallback(Action beginCallback, Action endCallback)
|
|
53
80
|
{
|
|
81
|
+
GDKUtils.ThrowIf(!Config.enableAudioModule, "Audio Module is disabled, Please enable it in the AmaGDKConfig");
|
|
82
|
+
|
|
54
83
|
if (beginCallback != null)
|
|
55
84
|
{
|
|
56
85
|
dispatcher.AddListener(Event.GDK_AUDIO_INTERRUPT_BEGIN, beginCallback);
|
|
@@ -74,8 +103,8 @@ namespace Amanotes.Core
|
|
|
74
103
|
_audioDeviceDetector.RegisterEvents();
|
|
75
104
|
RegisterCallbacks();
|
|
76
105
|
|
|
77
|
-
|
|
78
|
-
|
|
106
|
+
currentDevice = DetectAudioInfo();
|
|
107
|
+
currentDevice.latencyMs = GetAudioDeviceLatency();
|
|
79
108
|
}
|
|
80
109
|
|
|
81
110
|
private static AudioDeviceInfo DetectAudioInfo()
|
|
@@ -89,9 +118,9 @@ namespace Amanotes.Core
|
|
|
89
118
|
var info = _audioDeviceDetector.GetInfo();
|
|
90
119
|
return new AudioDeviceInfo
|
|
91
120
|
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
121
|
+
type = info.AudioDeviceType,
|
|
122
|
+
rawType = info.RawType,
|
|
123
|
+
name = info.Name
|
|
95
124
|
};
|
|
96
125
|
}
|
|
97
126
|
}
|
|
@@ -112,9 +141,9 @@ namespace Amanotes.Core
|
|
|
112
141
|
{
|
|
113
142
|
GDKUtils.DelayCall(1f, () =>
|
|
114
143
|
{
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
dispatcher.Dispatch(Event.GDK_AUDIO_INFO_CHANGE,
|
|
144
|
+
currentDevice = DetectAudioInfo();
|
|
145
|
+
currentDevice.latencyMs = GetAudioDeviceLatency();
|
|
146
|
+
dispatcher.Dispatch(Event.GDK_AUDIO_INFO_CHANGE, currentDevice);
|
|
118
147
|
});
|
|
119
148
|
}
|
|
120
149
|
|
|
@@ -129,10 +158,12 @@ namespace Amanotes.Core
|
|
|
129
158
|
{
|
|
130
159
|
public static bool IsConnectingBluetoothHeadset()
|
|
131
160
|
{
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
161
|
+
GDKUtils.ThrowIf(!Config.enableAudioModule, "Audio Module is disabled, Please enable it in the AmaGDKConfig");
|
|
162
|
+
|
|
163
|
+
return currentDevice != null
|
|
164
|
+
&& (currentDevice.rawType == "AVAudioSessionPortBluetoothA2DP"
|
|
165
|
+
|| currentDevice.rawType == "TYPE_BLUETOOTH_A2DP"
|
|
166
|
+
|| currentDevice.rawType == "AVAudioSessionPortBluetoothHFP");
|
|
136
167
|
}
|
|
137
168
|
|
|
138
169
|
private static string GetCurrentRouteInputs()
|
|
@@ -146,6 +177,7 @@ namespace Amanotes.Core
|
|
|
146
177
|
|
|
147
178
|
public static bool IsRecordingWithMicrophone()
|
|
148
179
|
{
|
|
180
|
+
GDKUtils.ThrowIf(!Config.enableAudioModule, "Audio Module is disabled, Please enable it in the AmaGDKConfig");
|
|
149
181
|
#if UNITY_IOS
|
|
150
182
|
string currentAudioInputs = GetCurrentRouteInputs();
|
|
151
183
|
return string.IsNullOrWhiteSpace(currentAudioInputs) == false;
|
|
@@ -243,7 +243,7 @@ public class GDKAudioDeviceDetector
|
|
|
243
243
|
|
|
244
244
|
private static String toTypeString(int AudioDeviceType)
|
|
245
245
|
{
|
|
246
|
-
return DEVICE_TYPE_MAP.
|
|
246
|
+
return DEVICE_TYPE_MAP.containsKey(AudioDeviceType) ? DEVICE_TYPE_MAP.get(AudioDeviceType) : "TYPE_UNKNOWN";
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
// API For Version before M
|
package/Runtime/Fps/AmaFPS.cs
CHANGED
|
@@ -87,8 +87,8 @@ namespace Amanotes.Core
|
|
|
87
87
|
public bool enabled = true;
|
|
88
88
|
public Graphic graphic = null;
|
|
89
89
|
|
|
90
|
-
public int
|
|
91
|
-
public int
|
|
90
|
+
public int lowerFPSBoundary = 15;
|
|
91
|
+
public int upperFPSBoundary = 60;
|
|
92
92
|
public int goodFPS = 55;
|
|
93
93
|
public int acceptableFPS = 45;
|
|
94
94
|
public int badFPS = 30;
|
|
@@ -128,8 +128,8 @@ namespace Amanotes.Core
|
|
|
128
128
|
{
|
|
129
129
|
var idx = (i + stIndex) % RESOLUTION;
|
|
130
130
|
var fps = fpsHistory[idx];
|
|
131
|
-
var h = fps <=
|
|
132
|
-
fps >=
|
|
131
|
+
var h = fps <= lowerFPSBoundary ? 0 :
|
|
132
|
+
fps >= upperFPSBoundary ? 1 : (fps - lowerFPSBoundary) / (upperFPSBoundary - lowerFPSBoundary);
|
|
133
133
|
|
|
134
134
|
var v0 = new Vector3(barX, 0, 0);
|
|
135
135
|
var v1 = new Vector3(barX, h * barH, 0);
|
|
@@ -155,9 +155,9 @@ namespace Amanotes.Core
|
|
|
155
155
|
barX += barW;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
AddHorzLine(vh, rect.width, barH * ((goodFPS-
|
|
159
|
-
AddHorzLine(vh, rect.width, barH * ((acceptableFPS-
|
|
160
|
-
AddHorzLine(vh, rect.width, barH * ((badFPS-
|
|
158
|
+
AddHorzLine(vh, rect.width, barH * ((goodFPS-lowerFPSBoundary) / (float)(upperFPSBoundary-lowerFPSBoundary)), colors[2], 2f);
|
|
159
|
+
AddHorzLine(vh, rect.width, barH * ((acceptableFPS-lowerFPSBoundary) / (float)(upperFPSBoundary-lowerFPSBoundary)), colors[1], 2f);
|
|
160
|
+
AddHorzLine(vh, rect.width, barH * ((badFPS-lowerFPSBoundary) / (float)(upperFPSBoundary-lowerFPSBoundary)), colors[0], 2f);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
void AddHorzLine(VertexHelper vh, float w, float h, Color color, float thickness = 1f)
|
|
@@ -100,7 +100,7 @@ namespace Amanotes.Core.Internal
|
|
|
100
100
|
GUI.DrawTextureWithTexCoords(new Rect(x + l, y + t, centerX, centerY), texture, new Rect(lu, bv, ru - lu, tv - bv));
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
public static void SectionLabel(
|
|
103
|
+
public static void SectionLabel(GUIContent text)
|
|
104
104
|
{
|
|
105
105
|
if (BIG_LABEL == null)
|
|
106
106
|
{
|
|
@@ -7,7 +7,9 @@ namespace Amanotes.Core.Internal
|
|
|
7
7
|
{
|
|
8
8
|
public partial class ConfigAsset
|
|
9
9
|
{
|
|
10
|
-
[SerializeField]
|
|
10
|
+
[SerializeField]
|
|
11
|
+
[Tooltip("Enable to get countryCode automatically, provided by '"+ CountryIS_GeoLocationProvider.URL + "'\n\ndefault: OFF")]
|
|
12
|
+
public bool enableGeoLocation = false;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
internal class GDKGeoLocation
|
|
@@ -58,7 +58,7 @@ namespace Amanotes.Core
|
|
|
58
58
|
|
|
59
59
|
internal class WorldTimeServer_TimeProvider : BaseServerTimeProvider
|
|
60
60
|
{
|
|
61
|
-
|
|
61
|
+
internal const string URL = "https://www.worldtimeserver.com/current_time_in_LA.aspx";
|
|
62
62
|
|
|
63
63
|
public override ServerTimeData ParseResponse(string response)
|
|
64
64
|
{
|
|
@@ -90,7 +90,7 @@ namespace Amanotes.Core
|
|
|
90
90
|
|
|
91
91
|
internal class WorldTimeAPI_TimeProvider : BaseServerTimeProvider
|
|
92
92
|
{
|
|
93
|
-
|
|
93
|
+
internal const string URL = "https://worldtimeapi.org/api/ip";
|
|
94
94
|
|
|
95
95
|
[Serializable]
|
|
96
96
|
private class TimeData
|
|
@@ -123,18 +123,21 @@ namespace Amanotes.Core.Internal
|
|
|
123
123
|
{
|
|
124
124
|
public partial class ConfigAsset
|
|
125
125
|
{
|
|
126
|
-
[SerializeField]
|
|
126
|
+
[SerializeField]
|
|
127
|
+
[Tooltip("Enable to get serverTime automatically, provided by\n\n'"+ WorldTimeAPI_TimeProvider.URL + "'\n'" + WorldTimeServer_TimeProvider.URL+ "'\n\ndefault: OFF" )]
|
|
128
|
+
public bool enableServerTime = false;
|
|
127
129
|
}
|
|
128
130
|
|
|
129
131
|
internal class GDKServerTime
|
|
130
132
|
{
|
|
131
133
|
private const float MAX_WAIT_TIME = 60;
|
|
132
|
-
private List<IServerTimeProvider> providers = new List<IServerTimeProvider>()
|
|
133
|
-
private int currentIndex = 0;
|
|
134
|
-
private IServerTimeProvider provider
|
|
134
|
+
private List<IServerTimeProvider> providers = new List<IServerTimeProvider>()
|
|
135
135
|
{
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
new WorldTimeAPI_TimeProvider(),
|
|
137
|
+
new WorldTimeServer_TimeProvider()
|
|
138
|
+
};
|
|
139
|
+
private int currentIndex = 0;
|
|
140
|
+
private IServerTimeProvider provider => providers[currentIndex];
|
|
138
141
|
|
|
139
142
|
private DateTime? serverTime;
|
|
140
143
|
private float timeSinceFetchServerTime;
|
|
@@ -144,7 +147,7 @@ namespace Amanotes.Core.Internal
|
|
|
144
147
|
{
|
|
145
148
|
}
|
|
146
149
|
|
|
147
|
-
|
|
150
|
+
internal void SetTimeProviders(List<IServerTimeProvider> providers)
|
|
148
151
|
{
|
|
149
152
|
GDKUtils.ThrowIf(providers == null || providers.Count == 0, "Server time providers list cannot be null or empty.");
|
|
150
153
|
this.providers = providers;
|
|
@@ -173,7 +176,7 @@ namespace Amanotes.Core.Internal
|
|
|
173
176
|
}
|
|
174
177
|
}
|
|
175
178
|
|
|
176
|
-
|
|
179
|
+
internal void UpdateTime(Action<DateTime?> result = null)
|
|
177
180
|
{
|
|
178
181
|
provider.FetchServerTime(data =>
|
|
179
182
|
{
|