com.amanotes.gdk 0.1.10 → 0.1.12

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +15 -2
  2. package/Editor/AmaGDKEditor.cs +61 -75
  3. package/Editor/AmaGDKManager.cs +236 -0
  4. package/Editor/AmaGDKManager.cs.meta +11 -0
  5. package/Editor/Resources/amasdk-modules.json +31 -0
  6. package/Editor/Resources/amasdk-modules.json.meta +7 -0
  7. package/Editor/Resources.meta +8 -0
  8. package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs +212 -0
  9. package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs.meta +11 -0
  10. package/Editor/Utils/AmaGDKEditor.GUI.cs +182 -0
  11. package/Editor/Utils/AmaGDKEditor.GUI.cs.meta +11 -0
  12. package/Editor/Utils/AmaGDKEditor.Utils.cs +35 -0
  13. package/Editor/Utils/AmaGDKEditor.Utils.cs.meta +11 -0
  14. package/Editor/Utils.meta +8 -0
  15. package/Packages/AmaGDKConfig.unitypackage +0 -0
  16. package/Packages/AmaGDKExample.unitypackage +0 -0
  17. package/Packages/AmaGDKExample.unitypackage.meta +7 -0
  18. package/Packages/AppsFlyerAdapter_v6.5.4.unitypackage +0 -0
  19. package/Packages/AppsFlyerAdapter_v6.5.4.unitypackage.meta +7 -0
  20. package/Packages/FirebaseAnalyticsAdapter_v9.1.0.unitypackage +0 -0
  21. package/Runtime/AmaGDK.Ads.cs +2 -2
  22. package/Runtime/AmaGDK.Analytics.cs +88 -17
  23. package/Runtime/AmaGDK.Config.cs +2 -2
  24. package/Runtime/AmaGDK.Internal.SemVer.cs +117 -0
  25. package/Runtime/AmaGDK.Internal.SemVer.cs.meta +11 -0
  26. package/Runtime/AmaGDK.Internal.cs +25 -1
  27. package/Runtime/AmaGDK.UserProfile.cs +1 -1
  28. package/Runtime/AmaGDK.cs +5 -13
  29. package/Samples~/Example/AmaGDKExample.cs +87 -0
  30. package/Samples~/Example/AmaGDKExample.cs.meta +11 -0
  31. package/Samples~/Example/AmaGDKExample.unity +3114 -0
  32. package/Samples~/Example/AmaGDKExample.unity.meta +7 -0
  33. package/Sample~/Example/AmaGDKExample.cs +87 -0
  34. package/Sample~/Example/AmaGDKExample.cs.meta +11 -0
  35. package/Sample~/Example/AmaGDKExample.unity +3114 -0
  36. package/Sample~/Example/AmaGDKExample.unity.meta +7 -0
  37. package/package.json +1 -1
@@ -0,0 +1,212 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.IO;
4
+ using System.Linq;
5
+ using System.Reflection;
6
+ using System.Xml;
7
+ using Amanotes.Core.Internal;
8
+ using UnityEngine;
9
+ using static Amanotes.Core.AmaGDK.AdapterID;
10
+
11
+ namespace Amanotes.Editor
12
+ {
13
+ [Serializable] internal class SDKStatus
14
+ {
15
+ public string sdkId;
16
+ public SemVer sdkVersion;
17
+ public SemVer adapterVersion;
18
+
19
+ public bool sdkInstalled { get { return sdkVersion > SemVer.ZERO; }}
20
+ public bool adapterInstalled { get { return sdkVersion > SemVer.ZERO; }}
21
+
22
+ public string ToTSVString()
23
+ {
24
+ return $"{sdkId}\t{sdkVersion}\t{adapterVersion}";
25
+ }
26
+
27
+ //
28
+
29
+ static readonly public Dictionary<string, SDKStatus> _cache = new Dictionary<string, SDKStatus>();
30
+ static public SDKStatus Get(string sdkId, bool force = false){
31
+ if (!force && _cache.TryGetValue(sdkId, out var result)) return result;
32
+
33
+ result = new SDKStatus(){
34
+ sdkId = sdkId,
35
+ adapterVersion = new SemVer(ExtractVersion.GDKAdapter(sdkId)),
36
+ sdkVersion = new SemVer(ExtractVersion.ThirdParty(sdkId))
37
+ };
38
+
39
+ if (_cache.ContainsKey(sdkId)){
40
+ _cache[sdkId] = result;
41
+ } else {
42
+ _cache.Add(sdkId, result);
43
+ }
44
+
45
+ return result;
46
+ }
47
+ }
48
+
49
+ public class ExtractVersion
50
+ {
51
+ public static string GDKAdapter(string sdkId)
52
+ {
53
+ string version = null;
54
+ var adapterId = sdkId + "Adapter";
55
+ // Debug.Log($"Searching for AdapterId: {adapterId}");
56
+ List<Assembly> assemblies = AppDomain.CurrentDomain.GetAssemblies().ToList();
57
+ if (assemblies != null)
58
+ {
59
+ foreach (Assembly assembly in assemblies)
60
+ {
61
+ foreach (Type oType in assembly.GetTypes())
62
+ {
63
+ if (!oType.Name.Equals(adapterId)) continue;
64
+
65
+ var field = oType.GetField("VERSION");
66
+ if (field == null) {
67
+ // Debug.Log("Found: " + oType + " --> " + field);
68
+ continue;
69
+ }
70
+
71
+ version = field.GetValue(null).ToString();
72
+ return version;
73
+ }
74
+ }
75
+ }
76
+ return version;
77
+ }
78
+
79
+ public static string ThirdParty(string sdkId)
80
+ {
81
+ string version = null;
82
+ switch (sdkId)
83
+ {
84
+ case FIREBASE_ANALYTICS : return FirebaseAnalytics();
85
+ case FIREBASE_REMOTE_CONFIG : return FirebaseRemoteConfig();
86
+ case APPSFLYER : return AppsFlyer();
87
+ case IRONSOURCE : return Ironsource();
88
+ case REVENUECAT : return RevenueCat();
89
+ default:
90
+ Debug.LogWarning($"Unsupported sdkID <{sdkId}>");
91
+ break;
92
+ }
93
+ return version;
94
+ }
95
+
96
+ internal static string FirebaseAnalytics()
97
+ {
98
+ string version = null;
99
+ string[] filesFirebase = Directory.GetFiles("Assets", "maven-metadata.xml", SearchOption.AllDirectories);
100
+ if (filesFirebase != null && filesFirebase.Length > 0)
101
+ {
102
+ for (int i = 0; i < filesFirebase.Length; i++)
103
+ {
104
+ XmlDocument Xdoc = new XmlDocument();
105
+
106
+ Xdoc.Load(filesFirebase[i]);
107
+ XmlElement root = Xdoc.DocumentElement;
108
+
109
+ XmlNode dataName = root.SelectSingleNode("artifactId");
110
+ XmlNode dataVersion = root.SelectSingleNode("versioning/release");
111
+
112
+ if (dataName.InnerText.Contains("firebase-analytics-unity"))
113
+ {
114
+ version = dataVersion.InnerText;
115
+ break;
116
+ }
117
+ }
118
+ }
119
+ return version;
120
+ }
121
+
122
+ internal static string FirebaseRemoteConfig()
123
+ {
124
+ string version = null;
125
+ string[] filesFirebase = Directory.GetFiles("Assets", "maven-metadata.xml", SearchOption.AllDirectories);
126
+ if (filesFirebase != null && filesFirebase.Length > 0)
127
+ {
128
+ for (int i = 0; i < filesFirebase.Length; i++)
129
+ {
130
+ XmlDocument Xdoc = new XmlDocument();
131
+
132
+ Xdoc.Load(filesFirebase[i]);
133
+ XmlElement root = Xdoc.DocumentElement;
134
+
135
+ XmlNode dataName = root.SelectSingleNode("artifactId");
136
+ XmlNode dataVersion = root.SelectSingleNode("versioning/release");
137
+
138
+ if (dataName.InnerText.Contains("firebase-config-unity"))
139
+ {
140
+ version = dataVersion.InnerText;
141
+ break;
142
+ }
143
+ }
144
+ }
145
+ return version;
146
+ }
147
+
148
+ internal static string AppsFlyer()
149
+ {
150
+ string version = null;
151
+ List<Assembly> assemblies = AppDomain.CurrentDomain.GetAssemblies().ToList();
152
+ if (assemblies != null)
153
+ {
154
+ foreach (Assembly assembly in assemblies)
155
+ {
156
+ foreach (Type oType in assembly.GetTypes())
157
+ {
158
+ if (oType.Name.Equals("AppsFlyer"))
159
+ {
160
+ version = oType.GetField("kAppsFlyerPluginVersion").GetValue(null).ToString();
161
+ }
162
+ }
163
+ }
164
+ }
165
+
166
+ return version;
167
+ }
168
+
169
+ internal static string Ironsource()
170
+ {
171
+ string version = null;
172
+ string[] issdk = Directory.GetFiles("Assets", "IronSourceSDKDependencies.xml", System.IO.SearchOption.AllDirectories);
173
+ if (issdk != null && issdk.Length > 0)
174
+ {
175
+ XmlDocument Xdoc2 = new XmlDocument();
176
+ Xdoc2.Load(issdk[0]);
177
+ XmlElement root2 = Xdoc2.DocumentElement;
178
+ XmlNode dataVersion2 = root2.SelectSingleNode("unityversion");
179
+ version = dataVersion2.InnerText;
180
+ }
181
+ return version;
182
+ }
183
+
184
+ internal static string RevenueCat()
185
+ {
186
+ string[] files = Directory.GetFiles("Assets", "PurchasesWrapper.java", SearchOption.AllDirectories);
187
+ string searchString = "PLUGIN_VERSION";
188
+ string version = null;
189
+ if (files.Length < 1)
190
+ {
191
+ return version;
192
+ }
193
+
194
+ foreach (string file in files)
195
+ {
196
+ using (StreamReader r = new StreamReader(file))
197
+ {
198
+ string line;
199
+ while ((line = r.ReadLine()) != null)
200
+ {
201
+ if (line.Contains(searchString))
202
+ {
203
+ version = line.Split('=')[1].Replace("\"", "").Replace(";", "");
204
+ break;
205
+ }
206
+ }
207
+ }
208
+ }
209
+ return version;
210
+ }
211
+ }
212
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: af8cb580d63b0488389312d877a7ef4a
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,182 @@
1
+ using System;
2
+ using Amanotes.Core.Internal;
3
+ using UnityEditor;
4
+ using UnityEngine;
5
+
6
+ namespace Amanotes.Editor
7
+ {
8
+ public static class AmaGUI
9
+ {
10
+ static Color LIGHT_BLUE = new Color(0.2f, 0.45f, 1f);
11
+ static Color LIGHT_GRAY = new Color(0.6f, 0.6f, 0.6f);
12
+ static Color DARK = new Color(0.15f, 0.15f, 0.15f, 1f);
13
+
14
+ static GUIStyle BIG_LABEL = null;
15
+
16
+ public static void SectionLabel(string text)
17
+ {
18
+ if (BIG_LABEL == null)
19
+ {
20
+ BIG_LABEL = new GUIStyle(UnityEngine.GUI.skin.label)
21
+ {
22
+ fontSize = 18,
23
+ alignment = TextAnchor.MiddleCenter,
24
+ richText = true
25
+ };
26
+
27
+ BIG_LABEL.normal.textColor = Color.white;
28
+ }
29
+
30
+ Rect rect = GUILayoutUtility.GetRect(Screen.width, 32);
31
+ rect.xMin -= 16f;
32
+ EditorGUI.DrawRect(rect, DARK);
33
+ EditorGUI.LabelField(rect, text, BIG_LABEL);
34
+ }
35
+
36
+ public static bool BigButton(string label, float height = 16f, Color? color = null, float colorMod = 0.5f)
37
+ {
38
+ var bgColor = UnityEngine.GUI.backgroundColor;
39
+
40
+ bool result;
41
+ if (color != null)
42
+ {
43
+ var c = (colorMod < 0f) ? Color.Lerp(color.Value, Color.black, -colorMod)
44
+ : (colorMod > 0f) ? Color.Lerp(color.Value, Color.white, colorMod) : color.Value;
45
+ UnityEngine.GUI.backgroundColor = c;
46
+ }
47
+ {
48
+ result = GUILayout.Button(label, GUILayout.Height(height));
49
+ }
50
+ if (color != null) UnityEngine.GUI.backgroundColor = bgColor;
51
+ return result;
52
+ }
53
+
54
+ public static bool Toggle(string label, ref bool value)
55
+ {
56
+ var newValue = EditorGUILayout.Toggle(label, value);
57
+ if (newValue == value) return false;
58
+
59
+ value = newValue;
60
+ return true;
61
+ }
62
+
63
+ public static bool ToggleGroup(string label, ref bool isOpen, Action drawFunc, Action titleFunc = null)
64
+ {
65
+ GUILayout.BeginHorizontal();
66
+ var newValue = EditorGUILayout.Foldout(isOpen, label);
67
+ var changed = newValue != isOpen;
68
+ titleFunc?.Invoke();
69
+ GUILayout.EndHorizontal();
70
+
71
+ if (isOpen)
72
+ {
73
+ EditorGUI.indentLevel++;
74
+ drawFunc();
75
+ EditorGUI.indentLevel--;
76
+ }
77
+
78
+ if (!changed) return false;
79
+
80
+ isOpen = newValue;
81
+ return true;
82
+ }
83
+
84
+ static readonly Texture2D TAG_0 = (Texture2D)EditorGUIUtility.IconContent("sv_label_0").image;
85
+ static readonly Texture2D TAG_1 = (Texture2D)EditorGUIUtility.IconContent("sv_icon_dot1_pix16_gizmo").image;
86
+ static GUIStyle versionStyle;
87
+ static GUIStyle tagLabelStyle;
88
+
89
+ public static void SemVerGUI(string title, SemVer version)
90
+ {
91
+ if (versionStyle == null){
92
+ versionStyle = new GUIStyle(EditorStyles.miniBoldLabel)
93
+ {
94
+ alignment = TextAnchor.MiddleCenter
95
+ };
96
+ }
97
+
98
+ var rect = GUILayoutUtility.GetRect(100, 16f);
99
+ var rect1 = rect;
100
+
101
+ rect1.width /= 2;
102
+ var rect2 = rect1;
103
+ rect2.x += rect.width / 2f;
104
+
105
+ GUI.Box(rect, GUIContent.none);
106
+ DrawTag(rect2, version.ToString(), version.isValid ? LIGHT_BLUE : LIGHT_GRAY, 0.5f, 2f);
107
+
108
+ rect1.xMin += 4f;
109
+ GUI.Label(rect1, title, versionStyle);
110
+ }
111
+
112
+ public static void DrawSDKStatus(string sdkId){
113
+ var status = SDKStatus.Get(sdkId);
114
+ GUILayout.BeginHorizontal();
115
+ {
116
+ GUILayout.Label(ObjectNames.NicifyVariableName(sdkId), EditorStyles.boldLabel);
117
+ GUILayout.FlexibleSpace();
118
+ SemVerGUI("SDK", status.sdkVersion);
119
+ GUILayout.Space(4);
120
+ SemVerGUI("Adapter", status.adapterVersion);
121
+ }
122
+ GUILayout.EndHorizontal();
123
+ }
124
+
125
+ public static void DrawTag(Rect rect, string label, Color tagColor, float alpha = 1f, float margin = 2f)
126
+ {
127
+ if (tagLabelStyle == null){
128
+ tagLabelStyle = new GUIStyle(EditorStyles.miniBoldLabel)
129
+ {
130
+ alignment = TextAnchor.MiddleCenter
131
+ };
132
+ }
133
+
134
+ rect.xMin += margin;
135
+ rect.xMax -= margin;
136
+ rect.yMin += margin;
137
+ rect.yMax -= margin;
138
+
139
+ tagColor.a = alpha;
140
+ GUI.DrawTexture(rect, Texture2D.whiteTexture, ScaleMode.StretchToFill, false, 1f, tagColor, 0f, 5f);
141
+
142
+ rect.xMin += 4f;
143
+ GUI.Label(rect, label, versionStyle);
144
+ }
145
+
146
+ public static void Draw9Slice(Rect rect, Texture2D texture,
147
+ float l, float r, float t, float b)
148
+ {
149
+ float x = rect.x;
150
+ float y = rect.y;
151
+ float w = rect.width;
152
+ float h = rect.height;
153
+
154
+ float tw = texture.width;
155
+ float th = texture.height;
156
+
157
+ float lu = l / tw;
158
+ float ru = (tw - r) / tw;
159
+ float tv = (th-t) / th;
160
+ float bv = b / th;
161
+
162
+ // Calculate the sizes of the texture's center and corners.
163
+ float centerX = Mathf.Max(w - l - r, 0);
164
+ float centerY = Mathf.Max(h - t - b, 0);
165
+
166
+ // Draw the corners.
167
+ GUI.DrawTextureWithTexCoords(new Rect(x, y, l, t), texture, new Rect(0, tv, lu, t/th));
168
+ GUI.DrawTextureWithTexCoords(new Rect(x + w - r, y, r, t), texture, new Rect(ru, tv, r/tw, t/th));
169
+ GUI.DrawTextureWithTexCoords(new Rect(x, y + h - b, l, b), texture, new Rect(0, 0, lu, bv));
170
+ GUI.DrawTextureWithTexCoords(new Rect(x + w - r, y + h - b, r, b), texture, new Rect(ru, 0, r/tw, bv));
171
+
172
+ // Draw the edges.
173
+ GUI.DrawTextureWithTexCoords(new Rect(x + l, y, centerX, t), texture, new Rect(lu, tv, ru-lu, t/th));
174
+ GUI.DrawTextureWithTexCoords(new Rect(x, y + t, l, centerY), texture, new Rect(0, bv, lu, tv-bv));
175
+ GUI.DrawTextureWithTexCoords(new Rect(x + w - r, y + t, r, centerY), texture, new Rect(ru, bv, r/tw, tv-bv));
176
+ GUI.DrawTextureWithTexCoords(new Rect(x + l, y + h - b, centerX, b), texture, new Rect(lu, 0, ru-lu, bv));
177
+
178
+ // Draw the center.
179
+ GUI.DrawTextureWithTexCoords(new Rect(x + l, y + t, centerX, centerY), texture, new Rect(lu, bv, ru-lu, tv-bv));
180
+ }
181
+ }
182
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 3e22cadf10a36442f9c330cd96560105
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,35 @@
1
+ using System;
2
+ using System.Collections;
3
+ using UnityEditor;
4
+ using UnityEngine;
5
+
6
+ namespace Amanotes.Editor
7
+ {
8
+ public static class Utils
9
+ {
10
+ public static void StartEditorCoroutine(this IEnumerator update, Action end = null)
11
+ {
12
+ EditorApplication.CallbackFunction closureCallback = null;
13
+
14
+ closureCallback = () =>
15
+ {
16
+ try
17
+ {
18
+ if (update.MoveNext() == false)
19
+ {
20
+ end?.Invoke();
21
+ EditorApplication.update -= closureCallback;
22
+ }
23
+ }
24
+ catch (Exception ex)
25
+ {
26
+ end?.Invoke();
27
+ Debug.LogException(ex);
28
+ EditorApplication.update -= closureCallback;
29
+ }
30
+ };
31
+
32
+ EditorApplication.update += closureCallback;
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: f9a4ffdedf54b4782bb27923c4096eaa
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: 61beaa5df6bc4435b9a397f7bdd79ab7
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
Binary file
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 6d185dbf1f37b42ac94953317558aca6
3
+ DefaultImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: ab7f4809a233742778d8686d6d64cc7f
3
+ DefaultImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -122,7 +122,7 @@ namespace Amanotes.Core
122
122
  if (!adsModule.IsAdReady(AdType.Interstitial))
123
123
  {
124
124
  LogWarning("Interstitial is not ready");
125
- BeginCoroutine(IWaitShowInterstitial());
125
+ AmaGDK._instance.StartCoroutine(IWaitShowInterstitial());
126
126
  return;
127
127
  }
128
128
  adsModule.ShowInterstitial();
@@ -143,7 +143,7 @@ namespace Amanotes.Core
143
143
  if (!adsModule.IsAdReady(AdType.Reward))
144
144
  {
145
145
  LogWarning("Reward is not ready");
146
- BeginCoroutine(IWaitShowRewardedVideo());
146
+ AmaGDK._instance.StartCoroutine(IWaitShowRewardedVideo());
147
147
  return;
148
148
  }
149
149
  adsModule.ShowRewardedVideo();