com.amanotes.gdk 0.2.44 → 0.2.46
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 +9 -0
- package/Editor/AmaGDKEditor.cs +95 -67
- package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs +1 -3
- package/Extra/AmaGDKInstaller.unitypackage +0 -0
- package/Extra/AmaGDKProject.unitypackage +0 -0
- package/Packages/AmaGDKConfig.unitypackage +0 -0
- package/Packages/AmaGDKExample.unitypackage +0 -0
- package/Packages/AmaGDKTest.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter_v6.5.4.unitypackage +0 -0
- package/Packages/FirebaseAnalyticsAdapter_v9.1.0.unitypackage +0 -0
- package/Packages/FirebaseRemoteConfigAdapter_v9.1.0.unitypackage +0 -0
- package/Packages/IronSourceAdapter_v7.5.2.unitypackage +0 -0
- package/Packages/RevenueCatAdapter_v6.0.0.unitypackage +0 -0
- package/Runtime/AmaGDK.Ads.cs +11 -5
- package/Runtime/AmaGDK.UserProfile.cs +1 -1
- package/Runtime/AmaGDK.cs +1 -1
- package/{Editor/Utils/AmaGDKEditor.GUI.cs → Runtime/Internal/AmaGDK.Internal.AmaGUI.cs} +106 -86
- package/{Editor/Utils/AmaGDKEditor.GUI.cs.meta → Runtime/Internal/AmaGDK.Internal.AmaGUI.cs.meta} +1 -1
- package/Runtime/{AmaGDK.Utils.cs → Internal/AmaGDK.Utils.cs} +13 -6
- package/Runtime/Internal.meta +8 -0
- package/package.json +1 -1
- /package/Runtime/{AmaGDK.Internal.SemVer.cs → Internal/AmaGDK.Internal.SemVer.cs} +0 -0
- /package/Runtime/{AmaGDK.Internal.SemVer.cs.meta → Internal/AmaGDK.Internal.SemVer.cs.meta} +0 -0
- /package/Runtime/{AmaGDK.Internal.cs → Internal/AmaGDK.Internal.cs} +0 -0
- /package/Runtime/{AmaGDK.Internal.cs.meta → Internal/AmaGDK.Internal.cs.meta} +0 -0
- /package/Runtime/{AmaGDK.Utils.cs.meta → Internal/AmaGDK.Utils.cs.meta} +0 -0
- /package/Runtime/{AmaGDK.WebUtils.cs → Internal/AmaGDK.WebUtils.cs} +0 -0
- /package/Runtime/{AmaGDK.WebUtils.cs.meta → Internal/AmaGDK.WebUtils.cs.meta} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.46 - 2023-12-19]
|
|
4
|
+
- Cleaner UI interface for AmaGDK Inspector
|
|
5
|
+
- Add AmaGUI to centralize all GUI handles
|
|
6
|
+
- [Fix] OnAdResult callback being looped through calling StopWaitForAd
|
|
7
|
+
- [Fix] Exception while loading / parsing LoadJsonFromFile
|
|
8
|
+
|
|
9
|
+
## [0.2.45 - 2023-12-13]
|
|
10
|
+
- [Fix] Able to assign ama_device_id in Editor
|
|
11
|
+
|
|
3
12
|
## [0.2.44 - 2023-12-08]
|
|
4
13
|
- [Fix] Auto log Ad events
|
|
5
14
|
|
package/Editor/AmaGDKEditor.cs
CHANGED
|
@@ -7,7 +7,6 @@ using System.IO;
|
|
|
7
7
|
using UnityEditor;
|
|
8
8
|
using UnityEngine;
|
|
9
9
|
using static Amanotes.Core.Internal.Logging;
|
|
10
|
-
using static Amanotes.Editor.AmaGUI;
|
|
11
10
|
using static Amanotes.Core.AmaGDK.AdapterID;
|
|
12
11
|
|
|
13
12
|
namespace Amanotes.Editor
|
|
@@ -67,7 +66,7 @@ namespace Amanotes.Editor
|
|
|
67
66
|
|
|
68
67
|
GUILayout.BeginHorizontal();
|
|
69
68
|
{
|
|
70
|
-
if (BigButton("CREATE", 40f, BLUE))
|
|
69
|
+
if (AmaGUI.BigButton("CREATE", 40f, BLUE))
|
|
71
70
|
{
|
|
72
71
|
try
|
|
73
72
|
{
|
|
@@ -94,13 +93,13 @@ namespace Amanotes.Editor
|
|
|
94
93
|
{
|
|
95
94
|
if (sdk.autoInit)
|
|
96
95
|
{
|
|
97
|
-
Toggle("Auto Init", ref sdk.autoInit);
|
|
96
|
+
AmaGUI.Toggle("Auto Init", ref sdk.autoInit);
|
|
98
97
|
EditorUtility.SetDirty(sdk);
|
|
99
98
|
return;
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
EditorGUILayout.HelpBox("You disabled AmaGDK AutoInit\nMake sure to call AmaGDK.Init() manually!", MessageType.Warning);
|
|
103
|
-
if (BigButton("Enable AutoInit", 40f, BLUE))
|
|
102
|
+
if (AmaGUI.BigButton("Enable AutoInit", 40f, BLUE))
|
|
104
103
|
{
|
|
105
104
|
sdk.autoInit = true;
|
|
106
105
|
EditorUtility.SetDirty(sdk);
|
|
@@ -128,17 +127,18 @@ namespace Amanotes.Editor
|
|
|
128
127
|
|
|
129
128
|
adapterScanned = true;
|
|
130
129
|
|
|
131
|
-
|
|
130
|
+
string[] adapterPath = Directory.GetFiles(Res.PACKAGE_PATH, "*Adapter*.unitypackage", SearchOption.AllDirectories);
|
|
132
131
|
|
|
133
|
-
for (
|
|
132
|
+
for (var i = 0; i < adapterPath.Length; i++)
|
|
134
133
|
{
|
|
135
134
|
lstAdapter.Add(Path.GetFileName(adapterPath[i]));
|
|
136
135
|
}
|
|
137
136
|
}
|
|
137
|
+
|
|
138
138
|
private void DrawGUI_AdapterList()
|
|
139
139
|
{
|
|
140
140
|
UpdateListAdapter();
|
|
141
|
-
foreach (
|
|
141
|
+
foreach (string adapter in lstAdapter)
|
|
142
142
|
{
|
|
143
143
|
if (GUILayout.Button(ObjectNames.NicifyVariableName(adapter)))
|
|
144
144
|
{
|
|
@@ -157,6 +157,7 @@ namespace Amanotes.Editor
|
|
|
157
157
|
AssetDatabase.ImportPackage(package, false);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
+
|
|
160
161
|
private void DrawGUI_ColorPicker()
|
|
161
162
|
{
|
|
162
163
|
GUILayout.BeginHorizontal();
|
|
@@ -166,67 +167,55 @@ namespace Amanotes.Editor
|
|
|
166
167
|
}
|
|
167
168
|
GUILayout.EndHorizontal();
|
|
168
169
|
}
|
|
169
|
-
|
|
170
|
+
|
|
171
|
+
public void CopyVersion()
|
|
172
|
+
{
|
|
173
|
+
var sb = new StringBuilder();
|
|
174
|
+
sb.AppendLine("ID\tSDK VERSION\tADAPTER VERSION");
|
|
175
|
+
for (var i = 0; i < SDK_IDS.Length; i++)
|
|
176
|
+
{
|
|
177
|
+
var status = SDKStatus.Get(SDK_IDS[i]);
|
|
178
|
+
sb.AppendLine(status.ToTSVString());
|
|
179
|
+
if (status.sdkId != IRONSOURCE) continue;
|
|
180
|
+
if (!status.sdkInstalled || !status.adapterInstalled) continue;
|
|
181
|
+
|
|
182
|
+
List<IronSourceSDKAdapter> list = ExtractVersion.IronSourceAdapter();
|
|
183
|
+
for (var j = 0; j < list.Count; j++)
|
|
184
|
+
{
|
|
185
|
+
IronSourceSDKAdapter item = list[j];
|
|
186
|
+
sb.AppendLine($"IS{item.name}Adapter\t{item.version}");
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
var tsv = sb.ToString();
|
|
191
|
+
EditorGUIUtility.systemCopyBuffer = tsv;
|
|
192
|
+
Debug.Log($"Content of version_info.tsv copied to clipboard!\n\n{tsv}\n\n");
|
|
193
|
+
}
|
|
194
|
+
|
|
170
195
|
public override void OnInspectorGUI()
|
|
171
196
|
{
|
|
172
197
|
if (sdk == null) return;
|
|
173
198
|
|
|
174
199
|
// DrawGUI_ColorPicker();
|
|
175
|
-
SectionLabel($"<b>AmaGDK</b> <size=12><color=gray>v{AmaGDK.VERSION}</color></size>");
|
|
200
|
+
AmaGUI.SectionLabel($"<b>AmaGDK</b> <size=12><color=gray>v{AmaGDK.VERSION}</color></size>");
|
|
176
201
|
EditorGUILayout.Space();
|
|
177
|
-
|
|
202
|
+
|
|
178
203
|
for (var i = 0; i < SDK_IDS.Length; i++)
|
|
179
204
|
{
|
|
180
205
|
string id = SDK_IDS[i];
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
if (id == IRONSOURCE)
|
|
184
|
-
{
|
|
185
|
-
var lastRect = GUILayoutUtility.GetLastRect();
|
|
186
|
-
lastRect.width = 18f;
|
|
187
|
-
lastRect.y += 2f;
|
|
188
|
-
showIronSourceSDKAdapter = EditorGUI.Foldout(lastRect, showIronSourceSDKAdapter, "");
|
|
189
|
-
if (showIronSourceSDKAdapter)
|
|
190
|
-
{
|
|
191
|
-
DrawIRSAdapterVersions();
|
|
192
|
-
}
|
|
193
|
-
}
|
|
206
|
+
DrawAdapterDetail(id);
|
|
194
207
|
}
|
|
195
208
|
EditorGUILayout.Space();
|
|
196
|
-
|
|
197
|
-
if (GUILayout.Button("version_info.tsv -> Clipboard"))
|
|
198
|
-
{
|
|
199
|
-
var sb = new StringBuilder();
|
|
200
|
-
sb.AppendLine("ID\tSDK VERSION\tADAPTER VERSION");
|
|
201
|
-
for (var i = 0; i < SDK_IDS.Length; i++)
|
|
202
|
-
{
|
|
203
|
-
var status = SDKStatus.Get(SDK_IDS[i]);
|
|
204
|
-
sb.AppendLine(status.ToTSVString());
|
|
205
|
-
if (status.sdkId != IRONSOURCE) continue;
|
|
206
|
-
if (!status.sdkInstalled || !status.adapterInstalled) continue;
|
|
207
|
-
|
|
208
|
-
List<IronSourceSDKAdapter> list = ExtractVersion.IronSourceAdapter();
|
|
209
|
-
for (var j = 0; j < list.Count; j++)
|
|
210
|
-
{
|
|
211
|
-
var item = list[j];
|
|
212
|
-
sb.AppendLine($"IS{item.name}Adapter\t{item.version}");
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
var tsv = sb.ToString();
|
|
217
|
-
EditorGUIUtility.systemCopyBuffer = tsv;
|
|
218
|
-
Debug.Log($"Content of version_info.tsv copied to clipboard!\n\n{tsv}\n\n");
|
|
219
|
-
}
|
|
220
|
-
|
|
209
|
+
|
|
221
210
|
if (configAsset == null)
|
|
222
211
|
{
|
|
223
212
|
DrawGUI_ConfigMissing();
|
|
224
213
|
return;
|
|
225
214
|
}
|
|
226
|
-
|
|
215
|
+
|
|
227
216
|
DrawGUI_AutoInit();
|
|
228
|
-
|
|
229
|
-
|
|
217
|
+
AmaGUI.Foldout("Config", ref showConfigDetail, DrawGUI_ConfigDetail, DrawGUI_ConfigAsset);
|
|
218
|
+
AmaGUI.Foldout("Adapters", ref showAdapterInstaller, DrawGUI_AdapterList);
|
|
230
219
|
|
|
231
220
|
//("Example", ref showExampleDetail, DrawGUI_ExampleScene);
|
|
232
221
|
|
|
@@ -236,32 +225,71 @@ namespace Amanotes.Editor
|
|
|
236
225
|
}
|
|
237
226
|
}
|
|
238
227
|
|
|
239
|
-
private static
|
|
228
|
+
private static readonly Dictionary<string, bool> configOpen = new Dictionary<string, bool>();
|
|
229
|
+
private static void DrawAdapterDetail(string adapterId)
|
|
240
230
|
{
|
|
241
|
-
|
|
231
|
+
if (!configOpen.TryGetValue(adapterId, out bool isOpen))
|
|
242
232
|
{
|
|
243
|
-
|
|
233
|
+
configOpen.Add(adapterId, isOpen = false);
|
|
244
234
|
}
|
|
245
|
-
|
|
235
|
+
|
|
236
|
+
SDKStatus status = SDKStatus.Get(adapterId);
|
|
237
|
+
bool changed = AmaGUI.Foldout(ObjectNames.NicifyVariableName(adapterId), ref isOpen, () =>
|
|
238
|
+
{
|
|
239
|
+
DrawSDKConfig(adapterId, status);
|
|
240
|
+
}, () =>
|
|
241
|
+
{
|
|
242
|
+
GUILayout.FlexibleSpace();
|
|
243
|
+
AmaGUI.DrawVersionTag(status.sdkVersion, status.adapterInstalled);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
if (changed) configOpen[adapterId] = isOpen;
|
|
246
247
|
}
|
|
247
|
-
public static bool showIronSourceSDKAdapter = false;
|
|
248
248
|
|
|
249
|
-
|
|
249
|
+
private static void DrawSDKConfig(string adapterId, SDKStatus status)
|
|
250
|
+
{
|
|
251
|
+
if (!status.sdkInstalled)
|
|
252
|
+
{
|
|
253
|
+
EditorGUILayout.HelpBox($"{adapterId} SDK not installed", MessageType.Warning);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
if (!status.adapterInstalled)
|
|
257
|
+
{
|
|
258
|
+
EditorGUILayout.HelpBox($"{adapterId}-GDKAdapter not installed", MessageType.Warning);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (adapterId == IRONSOURCE)
|
|
263
|
+
{
|
|
264
|
+
DrawIRSAdapterVersions();
|
|
265
|
+
} else
|
|
266
|
+
{
|
|
267
|
+
EditorGUILayout.HelpBox("Config for <" + adapterId + "> should be shown here!", MessageType.Info);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// private static void DrawVersion(string label, string version)
|
|
272
|
+
// {
|
|
273
|
+
// EditorGUI.BeginDisabledGroup(true);
|
|
274
|
+
// {
|
|
275
|
+
// GUILayout.Label($"{label} v{version}", EditorStyles.largeLabel);
|
|
276
|
+
// }
|
|
277
|
+
// EditorGUI.EndDisabledGroup();
|
|
278
|
+
// }
|
|
279
|
+
|
|
280
|
+
public static void DrawInitOrder()
|
|
250
281
|
{
|
|
251
|
-
SDKStatus status = SDKStatus.Get(IRONSOURCE);
|
|
252
|
-
if (!status.sdkInstalled) return;
|
|
253
|
-
if (!status.adapterInstalled) return;
|
|
254
|
-
if (!showIronSourceSDKAdapter) return;
|
|
255
282
|
|
|
256
|
-
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
public static void DrawIRSAdapterVersions()
|
|
286
|
+
{
|
|
257
287
|
List<IronSourceSDKAdapter> list = ExtractVersion.IronSourceAdapter();
|
|
258
|
-
|
|
259
288
|
var color = new Color(0.0f, .5f, .5f, 1f);
|
|
260
|
-
|
|
289
|
+
AmaGUI.DrawListColumn(list, (item) =>
|
|
261
290
|
{
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
}
|
|
291
|
+
AmaGUI.SemVerGUI(item.name, item.semVer, color);
|
|
292
|
+
});
|
|
265
293
|
}
|
|
266
294
|
}
|
|
267
295
|
}
|
|
@@ -26,9 +26,7 @@ namespace Amanotes.Editor
|
|
|
26
26
|
|
|
27
27
|
[Serializable] public class SDKStatus
|
|
28
28
|
{
|
|
29
|
-
|
|
30
29
|
//
|
|
31
|
-
|
|
32
30
|
private static readonly Dictionary<string, SDKStatus> _cache = new Dictionary<string, SDKStatus>();
|
|
33
31
|
public string sdkId;
|
|
34
32
|
public SemVer adapterVersion;
|
|
@@ -184,7 +182,7 @@ namespace Amanotes.Editor
|
|
|
184
182
|
if (oType.Name.Equals("AdjustAndroid") || oType.Name.Equals("AdjustiOS") )
|
|
185
183
|
{
|
|
186
184
|
version = oType.GetField("sdkPrefix", BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(null).ToString();
|
|
187
|
-
version = version.StartsWith("unity") ? version.Substring(5) : "";
|
|
185
|
+
version = version != null && version.StartsWith("unity") ? version.Substring(5) : "";
|
|
188
186
|
}
|
|
189
187
|
}
|
|
190
188
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/Runtime/AmaGDK.Ads.cs
CHANGED
|
@@ -727,6 +727,14 @@ namespace Amanotes.Core.Internal
|
|
|
727
727
|
|
|
728
728
|
private void ShowAdRoutineCompleted(bool isSuccess)
|
|
729
729
|
{
|
|
730
|
+
ShowAdContext lastContext = Ads.context;
|
|
731
|
+
Ads.context = null;
|
|
732
|
+
if (lastContext == null)
|
|
733
|
+
{
|
|
734
|
+
LogWarning("Something wrong: lastContext == null!");
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
|
|
730
738
|
if (_loadState == LoadAdsState.Ready)
|
|
731
739
|
{
|
|
732
740
|
_loadState = isAdReady ? LoadAdsState.Ready : LoadAdsState.None;
|
|
@@ -736,8 +744,7 @@ namespace Amanotes.Core.Internal
|
|
|
736
744
|
_showState = isSuccess ? ShowAdsState.ShowSuccess : ShowAdsState.ShowFail;
|
|
737
745
|
|
|
738
746
|
// Extra callback
|
|
739
|
-
|
|
740
|
-
Ads.context.onAdResult?.Invoke(isSuccess);
|
|
747
|
+
lastContext.showFinishAt = Time.realtimeSinceStartup;
|
|
741
748
|
|
|
742
749
|
var localData = Ads.localData;
|
|
743
750
|
var stat = _isInterstitial ? localData.interstitial : localData.reward;
|
|
@@ -756,9 +763,8 @@ namespace Amanotes.Core.Internal
|
|
|
756
763
|
localData.Save();
|
|
757
764
|
HandleAfterAdShow();
|
|
758
765
|
|
|
759
|
-
Log($"[Ad] {adType} ShowAdRoutineCompleted: {isSuccess}\n{JsonUtility.ToJson(
|
|
760
|
-
|
|
761
|
-
_showState = ShowAdsState.None;
|
|
766
|
+
Log($"[Ad] {adType} ShowAdRoutineCompleted: {isSuccess}\n{JsonUtility.ToJson(lastContext)}");
|
|
767
|
+
lastContext.onAdResult?.Invoke(isSuccess);
|
|
762
768
|
}
|
|
763
769
|
|
|
764
770
|
private void HandleBeforeAdShow()
|
package/Runtime/AmaGDK.cs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
using Amanotes.Core.Internal;
|
|
3
|
-
using UnityEditor;
|
|
1
|
+
using System;
|
|
4
2
|
using UnityEngine;
|
|
5
|
-
|
|
3
|
+
|
|
4
|
+
#if UNITY_EDITOR
|
|
5
|
+
using System.Collections.Generic;
|
|
6
|
+
using UnityEditor;
|
|
7
|
+
namespace Amanotes.Core.Internal
|
|
6
8
|
{
|
|
7
9
|
internal static class AmaGUI
|
|
8
10
|
{
|
|
@@ -11,10 +13,9 @@ namespace Amanotes.Editor
|
|
|
11
13
|
private static readonly Color DARK = new Color(0.15f, 0.15f, 0.15f, 1f);
|
|
12
14
|
|
|
13
15
|
private static GUIStyle BIG_LABEL;
|
|
14
|
-
|
|
15
|
-
private static readonly Texture2D
|
|
16
|
-
private static readonly
|
|
17
|
-
private static GUIStyle versionStyle = new GUIStyle(EditorStyles.miniBoldLabel)
|
|
16
|
+
private static readonly Texture2D TAG_0 = (Texture2D) EditorGUIUtility.IconContent("sv_label_0").image;
|
|
17
|
+
private static readonly Texture2D TAG_1 = (Texture2D) EditorGUIUtility.IconContent("sv_icon_dot1_pix16_gizmo").image;
|
|
18
|
+
private static readonly GUIStyle versionStyle = new GUIStyle(EditorStyles.miniBoldLabel)
|
|
18
19
|
{
|
|
19
20
|
alignment = TextAnchor.MiddleCenter
|
|
20
21
|
};
|
|
@@ -23,6 +24,82 @@ namespace Amanotes.Editor
|
|
|
23
24
|
alignment = TextAnchor.MiddleCenter
|
|
24
25
|
};
|
|
25
26
|
|
|
27
|
+
public static void DrawListColumn<T>(IList<T> list, Action<T> draw, float minColumnWidth = 300)
|
|
28
|
+
{
|
|
29
|
+
int nCols = Mathf.Max(1, Mathf.FloorToInt(Screen.width / minColumnWidth));
|
|
30
|
+
int n = Mathf.CeilToInt(list.Count / (float)nCols);
|
|
31
|
+
|
|
32
|
+
GUILayout.BeginHorizontal();
|
|
33
|
+
{
|
|
34
|
+
for (var c = 0; c < nCols; c++)
|
|
35
|
+
{
|
|
36
|
+
GUILayout.BeginVertical();
|
|
37
|
+
{
|
|
38
|
+
int min = c * n;
|
|
39
|
+
int max = Mathf.Min(min + n, list.Count);
|
|
40
|
+
|
|
41
|
+
for (int i = min; i < max; i++)
|
|
42
|
+
{
|
|
43
|
+
draw(list[i]);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
GUILayout.EndVertical();
|
|
47
|
+
GUILayout.Space(4f);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
GUILayout.EndHorizontal();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
public static void DrawTag(Rect rect, string label, Color tagColor, float alpha = 1f, float margin = 1f)
|
|
55
|
+
{
|
|
56
|
+
rect.xMin += margin;
|
|
57
|
+
rect.xMax -= margin;
|
|
58
|
+
rect.yMin += margin;
|
|
59
|
+
rect.yMax -= margin;
|
|
60
|
+
|
|
61
|
+
tagColor.a = alpha;
|
|
62
|
+
GUI.DrawTexture(rect, Texture2D.whiteTexture, ScaleMode.StretchToFill, false, 1f, tagColor, 0f, 5f);
|
|
63
|
+
|
|
64
|
+
rect.xMin += 4f;
|
|
65
|
+
GUI.Label(rect, label, versionStyle);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public static void Draw9Slice(Rect rect, Texture2D texture, float l, float r, float t, float b)
|
|
69
|
+
{
|
|
70
|
+
float x = rect.x;
|
|
71
|
+
float y = rect.y;
|
|
72
|
+
float w = rect.width;
|
|
73
|
+
float h = rect.height;
|
|
74
|
+
|
|
75
|
+
float tw = texture.width;
|
|
76
|
+
float th = texture.height;
|
|
77
|
+
|
|
78
|
+
float lu = l / tw;
|
|
79
|
+
float ru = (tw - r) / tw;
|
|
80
|
+
float tv = (th - t) / th;
|
|
81
|
+
float bv = b / th;
|
|
82
|
+
|
|
83
|
+
// Calculate the sizes of the texture's center and corners.
|
|
84
|
+
float centerX = Mathf.Max(w - l - r, 0);
|
|
85
|
+
float centerY = Mathf.Max(h - t - b, 0);
|
|
86
|
+
|
|
87
|
+
// Draw the corners.
|
|
88
|
+
GUI.DrawTextureWithTexCoords(new Rect(x, y, l, t), texture, new Rect(0, tv, lu, t / th));
|
|
89
|
+
GUI.DrawTextureWithTexCoords(new Rect(x + w - r, y, r, t), texture, new Rect(ru, tv, r / tw, t / th));
|
|
90
|
+
GUI.DrawTextureWithTexCoords(new Rect(x, y + h - b, l, b), texture, new Rect(0, 0, lu, bv));
|
|
91
|
+
GUI.DrawTextureWithTexCoords(new Rect(x + w - r, y + h - b, r, b), texture, new Rect(ru, 0, r / tw, bv));
|
|
92
|
+
|
|
93
|
+
// Draw the edges.
|
|
94
|
+
GUI.DrawTextureWithTexCoords(new Rect(x + l, y, centerX, t), texture, new Rect(lu, tv, ru - lu, t / th));
|
|
95
|
+
GUI.DrawTextureWithTexCoords(new Rect(x, y + t, l, centerY), texture, new Rect(0, bv, lu, tv - bv));
|
|
96
|
+
GUI.DrawTextureWithTexCoords(new Rect(x + w - r, y + t, r, centerY), texture, new Rect(ru, bv, r / tw, tv - bv));
|
|
97
|
+
GUI.DrawTextureWithTexCoords(new Rect(x + l, y + h - b, centerX, b), texture, new Rect(lu, 0, ru - lu, bv));
|
|
98
|
+
|
|
99
|
+
// Draw the center.
|
|
100
|
+
GUI.DrawTextureWithTexCoords(new Rect(x + l, y + t, centerX, centerY), texture, new Rect(lu, bv, ru - lu, tv - bv));
|
|
101
|
+
}
|
|
102
|
+
|
|
26
103
|
public static void SectionLabel(string text)
|
|
27
104
|
{
|
|
28
105
|
if (BIG_LABEL == null)
|
|
@@ -31,13 +108,12 @@ namespace Amanotes.Editor
|
|
|
31
108
|
{
|
|
32
109
|
fontSize = 18,
|
|
33
110
|
alignment = TextAnchor.MiddleCenter,
|
|
34
|
-
richText = true
|
|
111
|
+
richText = true,
|
|
112
|
+
normal = { textColor = Color.white }
|
|
35
113
|
};
|
|
36
|
-
|
|
37
|
-
BIG_LABEL.normal.textColor = Color.white;
|
|
38
114
|
}
|
|
39
|
-
|
|
40
|
-
|
|
115
|
+
|
|
116
|
+
Rect rect = GUILayoutUtility.GetRect(Screen.width, 32);
|
|
41
117
|
rect.xMin -= 16f;
|
|
42
118
|
EditorGUI.DrawRect(rect, DARK);
|
|
43
119
|
EditorGUI.LabelField(rect, text, BIG_LABEL);
|
|
@@ -50,7 +126,7 @@ namespace Amanotes.Editor
|
|
|
50
126
|
bool result;
|
|
51
127
|
if (color != null)
|
|
52
128
|
{
|
|
53
|
-
|
|
129
|
+
Color c = colorMod < 0f ? Color.Lerp(color.Value, Color.black, -colorMod)
|
|
54
130
|
: colorMod > 0f ? Color.Lerp(color.Value, Color.white, colorMod) : color.Value;
|
|
55
131
|
GUI.backgroundColor = c;
|
|
56
132
|
}
|
|
@@ -67,13 +143,13 @@ namespace Amanotes.Editor
|
|
|
67
143
|
EditorGUIUtility.labelWidth = 220f;
|
|
68
144
|
bool newValue = EditorGUILayout.Toggle(label, value);
|
|
69
145
|
EditorGUIUtility.labelWidth = lbWidth;
|
|
70
|
-
|
|
146
|
+
|
|
71
147
|
if (newValue == value) return false;
|
|
72
148
|
value = newValue;
|
|
73
149
|
return true;
|
|
74
150
|
}
|
|
75
151
|
|
|
76
|
-
public static bool
|
|
152
|
+
public static bool Foldout(string label, ref bool isOpen, Action drawFunc, Action titleFunc = null)
|
|
77
153
|
{
|
|
78
154
|
GUILayout.BeginHorizontal();
|
|
79
155
|
bool newValue = EditorGUILayout.Foldout(isOpen, label);
|
|
@@ -93,92 +169,36 @@ namespace Amanotes.Editor
|
|
|
93
169
|
isOpen = newValue;
|
|
94
170
|
return true;
|
|
95
171
|
}
|
|
96
|
-
|
|
172
|
+
|
|
97
173
|
public static void SemVerGUI(string title, SemVer version, Color? color1 = null, Color? color2 = null)
|
|
98
174
|
{
|
|
99
175
|
const int TAG_SIZE = 60;
|
|
100
|
-
|
|
101
|
-
|
|
176
|
+
Rect rect = GUILayoutUtility.GetRect(120, 16f);
|
|
177
|
+
Rect rect1 = rect;
|
|
102
178
|
|
|
103
179
|
rect1.width /= 2;
|
|
104
|
-
|
|
180
|
+
Rect rect2 = rect1;
|
|
105
181
|
rect2.x += rect.width / 2f;
|
|
106
|
-
|
|
182
|
+
|
|
107
183
|
GUI.Box(rect, GUIContent.none);
|
|
108
|
-
rect2.xMin += (rect2.width-TAG_SIZE);
|
|
184
|
+
rect2.xMin += (rect2.width - TAG_SIZE);
|
|
109
185
|
rect2.width = TAG_SIZE;
|
|
110
186
|
|
|
111
|
-
|
|
112
|
-
|
|
187
|
+
color1 ??= LIGHT_BLUE;
|
|
188
|
+
color2 ??= LIGHT_GRAY;
|
|
113
189
|
DrawTag(rect2, version.ToString(), version.isValid ? color1.Value : color2.Value, 0.5f);
|
|
114
190
|
|
|
115
191
|
rect1.xMin += 4f;
|
|
116
192
|
rect1.width = rect.width - rect2.width;
|
|
117
193
|
GUI.Label(rect1, title, versionStyle);
|
|
118
194
|
}
|
|
119
|
-
|
|
120
|
-
public static void
|
|
121
|
-
{
|
|
122
|
-
var status = SDKStatus.Get(sdkId);
|
|
123
|
-
GUILayout.BeginHorizontal();
|
|
124
|
-
{
|
|
125
|
-
GUILayout.Label(ObjectNames.NicifyVariableName(sdkId), EditorStyles.boldLabel);
|
|
126
|
-
GUILayout.FlexibleSpace();
|
|
127
|
-
SemVerGUI("SDK", status.sdkVersion);
|
|
128
|
-
GUILayout.Space(4);
|
|
129
|
-
SemVerGUI("Adapter", status.adapterVersion);
|
|
130
|
-
}
|
|
131
|
-
GUILayout.EndHorizontal();
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
public static void DrawTag(Rect rect, string label, Color tagColor, float alpha = 1f, float margin = 1f)
|
|
135
|
-
{
|
|
136
|
-
rect.xMin += margin;
|
|
137
|
-
rect.xMax -= margin;
|
|
138
|
-
rect.yMin += margin;
|
|
139
|
-
rect.yMax -= margin;
|
|
140
|
-
|
|
141
|
-
tagColor.a = alpha;
|
|
142
|
-
GUI.DrawTexture(rect, Texture2D.whiteTexture, ScaleMode.StretchToFill, false, 1f, tagColor, 0f, 5f);
|
|
143
|
-
|
|
144
|
-
rect.xMin += 4f;
|
|
145
|
-
GUI.Label(rect, label, versionStyle);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
public static void Draw9Slice(Rect rect, Texture2D texture,
|
|
149
|
-
float l, float r, float t, float b)
|
|
195
|
+
|
|
196
|
+
public static void DrawVersionTag(SemVer version, bool? isValid = null)
|
|
150
197
|
{
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
float h = rect.height;
|
|
155
|
-
|
|
156
|
-
float tw = texture.width;
|
|
157
|
-
float th = texture.height;
|
|
158
|
-
|
|
159
|
-
float lu = l / tw;
|
|
160
|
-
float ru = (tw - r) / tw;
|
|
161
|
-
float tv = (th - t) / th;
|
|
162
|
-
float bv = b / th;
|
|
163
|
-
|
|
164
|
-
// Calculate the sizes of the texture's center and corners.
|
|
165
|
-
float centerX = Mathf.Max(w - l - r, 0);
|
|
166
|
-
float centerY = Mathf.Max(h - t - b, 0);
|
|
167
|
-
|
|
168
|
-
// Draw the corners.
|
|
169
|
-
GUI.DrawTextureWithTexCoords(new Rect(x, y, l, t), texture, new Rect(0, tv, lu, t / th));
|
|
170
|
-
GUI.DrawTextureWithTexCoords(new Rect(x + w - r, y, r, t), texture, new Rect(ru, tv, r / tw, t / th));
|
|
171
|
-
GUI.DrawTextureWithTexCoords(new Rect(x, y + h - b, l, b), texture, new Rect(0, 0, lu, bv));
|
|
172
|
-
GUI.DrawTextureWithTexCoords(new Rect(x + w - r, y + h - b, r, b), texture, new Rect(ru, 0, r / tw, bv));
|
|
173
|
-
|
|
174
|
-
// Draw the edges.
|
|
175
|
-
GUI.DrawTextureWithTexCoords(new Rect(x + l, y, centerX, t), texture, new Rect(lu, tv, ru - lu, t / th));
|
|
176
|
-
GUI.DrawTextureWithTexCoords(new Rect(x, y + t, l, centerY), texture, new Rect(0, bv, lu, tv - bv));
|
|
177
|
-
GUI.DrawTextureWithTexCoords(new Rect(x + w - r, y + t, r, centerY), texture, new Rect(ru, bv, r / tw, tv - bv));
|
|
178
|
-
GUI.DrawTextureWithTexCoords(new Rect(x + l, y + h - b, centerX, b), texture, new Rect(lu, 0, ru - lu, bv));
|
|
179
|
-
|
|
180
|
-
// Draw the center.
|
|
181
|
-
GUI.DrawTextureWithTexCoords(new Rect(x + l, y + t, centerX, centerY), texture, new Rect(lu, bv, ru - lu, tv - bv));
|
|
198
|
+
isValid ??= version.isValid;
|
|
199
|
+
Rect rect = GUILayoutUtility.GetRect(60f, 60f, 18f, 18f);
|
|
200
|
+
DrawTag(rect, version.ToString(), isValid.Value ? LIGHT_BLUE : LIGHT_GRAY, 0.5f);
|
|
182
201
|
}
|
|
183
202
|
}
|
|
184
203
|
}
|
|
204
|
+
#endif
|
|
@@ -253,14 +253,21 @@ namespace Amanotes.Core.Internal
|
|
|
253
253
|
{
|
|
254
254
|
public static T LoadJsonFromFile<T>(this T instance) where T : IJsonFile, new()
|
|
255
255
|
{
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
var result = new T();
|
|
259
|
-
instance = result;
|
|
260
|
-
}
|
|
256
|
+
instance ??= new T();
|
|
257
|
+
|
|
261
258
|
string fileName = instance.GetType().Name;
|
|
262
259
|
string json = GDKFileUtils.Load(fileName);
|
|
263
|
-
|
|
260
|
+
if (!string.IsNullOrEmpty(json))
|
|
261
|
+
{
|
|
262
|
+
try
|
|
263
|
+
{
|
|
264
|
+
JsonUtility.FromJsonOverwrite(json, instance);
|
|
265
|
+
} catch (Exception e)
|
|
266
|
+
{
|
|
267
|
+
LogWarning("LoadJsonFromFile error: " + fileName + "\n" + e);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
264
271
|
return instance;
|
|
265
272
|
}
|
|
266
273
|
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|