com.amanotes.gdk 0.1.3
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 +6 -0
- package/CHANGELOG.md.meta +7 -0
- package/Editor/AmaGDK.Editor.asmdef +18 -0
- package/Editor/AmaGDK.Editor.asmdef.meta +7 -0
- package/Editor/AmaGDKEditor.cs +210 -0
- package/Editor/AmaGDKEditor.cs.meta +11 -0
- package/Editor.meta +8 -0
- package/LICENSE.md +7 -0
- package/LICENSE.md.meta +7 -0
- package/Packages/AmaGDKConfig.unitypackage +0 -0
- package/Packages/AmaGDKConfig.unitypackage.meta +8 -0
- package/Packages/AppsflyerAdapter_v6.5.4.unitypackage +0 -0
- package/Packages/AppsflyerAdapter_v6.5.4.unitypackage.meta +7 -0
- package/Packages/FirebaseAnalyticsAdapter_v9.1.0.unitypackage +0 -0
- package/Packages/FirebaseAnalyticsAdapter_v9.1.0.unitypackage.meta +7 -0
- package/Packages.meta +8 -0
- package/README.md +44 -0
- package/README.md.meta +7 -0
- package/Runtime/AmaGDK.Adapters.cs +45 -0
- package/Runtime/AmaGDK.Adapters.cs.meta +11 -0
- package/Runtime/AmaGDK.Analytics.cs +454 -0
- package/Runtime/AmaGDK.Analytics.cs.meta +11 -0
- package/Runtime/AmaGDK.Config.cs +13 -0
- package/Runtime/AmaGDK.Config.cs.meta +11 -0
- package/Runtime/AmaGDK.Internal.cs +133 -0
- package/Runtime/AmaGDK.Internal.cs.meta +11 -0
- package/Runtime/AmaGDK.UserProfile.cs +41 -0
- package/Runtime/AmaGDK.UserProfile.cs.meta +11 -0
- package/Runtime/AmaGDK.Utils.cs +121 -0
- package/Runtime/AmaGDK.Utils.cs.meta +11 -0
- package/Runtime/AmaGDK.asmdef +14 -0
- package/Runtime/AmaGDK.asmdef.meta +7 -0
- package/Runtime/AmaGDK.cs +159 -0
- package/Runtime/AmaGDK.cs.meta +11 -0
- package/Runtime/AmaGDK.prefab +46 -0
- package/Runtime/AmaGDK.prefab.meta +8 -0
- package/Runtime/AssemblyInfo.cs +8 -0
- package/Runtime/AssemblyInfo.cs.meta +11 -0
- package/Runtime/Interfaces/Analytics/IAnalytics.cs +6 -0
- package/Runtime/Interfaces/Analytics/IAnalytics.cs.meta +11 -0
- package/Runtime/Interfaces/Analytics.meta +8 -0
- package/Runtime/Interfaces.meta +8 -0
- package/Runtime.meta +8 -0
- package/Tests/Editor/AmaGDK.Editor.Test.asmdef +23 -0
- package/Tests/Editor/AmaGDK.Editor.Test.asmdef.meta +7 -0
- package/Tests/Editor.meta +8 -0
- package/Tests/Runtime/AmaGDK.Test.asmdef +20 -0
- package/Tests/Runtime/AmaGDK.Test.asmdef.meta +7 -0
- package/Tests/Runtime/AmaGDKCoreTest.cs +229 -0
- package/Tests/Runtime/AmaGDKCoreTest.cs.meta +11 -0
- package/Tests/Runtime/MigrationTest.cs +165 -0
- package/Tests/Runtime/MigrationTest.cs.meta +11 -0
- package/Tests/Runtime.meta +8 -0
- package/Tests/TestScene00.unity +125 -0
- package/Tests/TestScene00.unity.meta +7 -0
- package/Tests/TestScene01.unity +199 -0
- package/Tests/TestScene01.unity.meta +7 -0
- package/Tests/TestScene02.unity +209 -0
- package/Tests/TestScene02.unity.meta +7 -0
- package/Tests/TestScene03.unity +599 -0
- package/Tests/TestScene03.unity.meta +7 -0
- package/Tests.meta +8 -0
- package/package.json +18 -0
- package/package.json.meta +7 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "AmaGDK.Editor",
|
|
3
|
+
"rootNamespace": "",
|
|
4
|
+
"references": [
|
|
5
|
+
"AmaGDK"
|
|
6
|
+
],
|
|
7
|
+
"includePlatforms": [
|
|
8
|
+
"Editor"
|
|
9
|
+
],
|
|
10
|
+
"excludePlatforms": [],
|
|
11
|
+
"allowUnsafeCode": false,
|
|
12
|
+
"overrideReferences": false,
|
|
13
|
+
"precompiledReferences": [],
|
|
14
|
+
"autoReferenced": true,
|
|
15
|
+
"defineConstraints": [],
|
|
16
|
+
"versionDefines": [],
|
|
17
|
+
"noEngineReferences": false
|
|
18
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
using UnityEditor;
|
|
3
|
+
using Amanotes.Core.Internal;
|
|
4
|
+
using System;
|
|
5
|
+
using static Amanotes.Core.Internal.Logging;
|
|
6
|
+
|
|
7
|
+
namespace Amanotes.Core
|
|
8
|
+
{
|
|
9
|
+
internal class EditorContext
|
|
10
|
+
{
|
|
11
|
+
[MenuItem("GameObject/AmaGDK/Add AmaGDK Prefab", false, 10)]
|
|
12
|
+
private static void AddPrefab_AmaGDK()
|
|
13
|
+
{
|
|
14
|
+
GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(Res.AMAGDK_PREFAB);
|
|
15
|
+
if (prefab == null)
|
|
16
|
+
{
|
|
17
|
+
Debug.LogWarning($"Prefab [AmaGDK] not found at: {Res.AMAGDK_PREFAB}");
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
GameObject newPrefab = PrefabUtility.InstantiatePrefab(prefab) as GameObject;
|
|
22
|
+
newPrefab.name = "AmaGDK";
|
|
23
|
+
Selection.activeObject = newPrefab;
|
|
24
|
+
Selection.activeObject = null;
|
|
25
|
+
Selection.activeObject = newPrefab;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
[CustomEditor(typeof(AmaGDK))]
|
|
30
|
+
public class AmaGDKEditor : Editor
|
|
31
|
+
{
|
|
32
|
+
static Color BLUE = new Color32(0x34, 0xFF, 0xF7, 0xFF);
|
|
33
|
+
|
|
34
|
+
static AmaGDK sdk;
|
|
35
|
+
static ConfigAsset configAsset;
|
|
36
|
+
static Editor editor;
|
|
37
|
+
|
|
38
|
+
static bool showConfigDetail;
|
|
39
|
+
static bool showAdapterInstaller;
|
|
40
|
+
|
|
41
|
+
public void OnEnable()
|
|
42
|
+
{
|
|
43
|
+
sdk = (AmaGDK)target;
|
|
44
|
+
if (sdk != null) sdk.transform.hideFlags = HideFlags.HideInInspector;
|
|
45
|
+
if (configAsset == null) SearchForConfigAsset();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
void SearchForConfigAsset()
|
|
49
|
+
{
|
|
50
|
+
Resources.UnloadUnusedAssets();
|
|
51
|
+
configAsset = Resources.Load<ConfigAsset>("AmaGDKConfig");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
void KeepSearchingForConfig()
|
|
55
|
+
{
|
|
56
|
+
if (EditorApplication.isUpdating || EditorApplication.isCompiling) return;
|
|
57
|
+
SearchForConfigAsset();
|
|
58
|
+
|
|
59
|
+
if (configAsset == null) return;
|
|
60
|
+
EditorApplication.update -= KeepSearchingForConfig;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
void DrawGUI_ConfigMissing()
|
|
64
|
+
{
|
|
65
|
+
EditorGUILayout.HelpBox("[Warning] AmaGDK ConfigAsset NOT FOUND!\nYou need to create one to control all the adapter's configurations!", MessageType.Warning);
|
|
66
|
+
|
|
67
|
+
GUILayout.BeginHorizontal();
|
|
68
|
+
{
|
|
69
|
+
if (GUIButton("CREATE", 40f, BLUE))
|
|
70
|
+
{
|
|
71
|
+
try
|
|
72
|
+
{
|
|
73
|
+
AssetDatabase.ImportPackage(Res.AMAGDK_CONFIG_PACKAGE, false);
|
|
74
|
+
EditorApplication.update -= KeepSearchingForConfig;
|
|
75
|
+
EditorApplication.update += KeepSearchingForConfig;
|
|
76
|
+
}
|
|
77
|
+
catch (Exception e)
|
|
78
|
+
{
|
|
79
|
+
LogError(Res.AMAGDK_CONFIG_PACKAGE + "\n" + e);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (GUILayout.Button(EditorGUIUtility.IconContent("d_Refresh@2x"), GUILayout.Width(40f), GUILayout.Height(40f)))
|
|
84
|
+
{
|
|
85
|
+
SearchForConfigAsset();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
GUILayout.EndHorizontal();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
void DrawGUI_AutoInit()
|
|
93
|
+
{
|
|
94
|
+
if (sdk.autoInit)
|
|
95
|
+
{
|
|
96
|
+
GUIToggle("Auto Init", ref sdk.autoInit);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
EditorGUILayout.HelpBox("You disabled AmaGDK AutoInit\nMake sure to call AmaGDK.Init() manually!", MessageType.Warning);
|
|
101
|
+
if (GUIButton("Enable AutoInit", 40f, BLUE))
|
|
102
|
+
{
|
|
103
|
+
sdk.autoInit = true;
|
|
104
|
+
EditorUtility.SetDirty(sdk);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
void DrawGUI_ConfigDetail()
|
|
109
|
+
{
|
|
110
|
+
CreateCachedEditor(configAsset, null, ref editor);
|
|
111
|
+
editor.OnInspectorGUI();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
void DrawGUI_ConfigAsset(){
|
|
115
|
+
EditorGUILayout.ObjectField(configAsset, configAsset.GetType(), false);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
void DrawGUI_AdapterList()
|
|
119
|
+
{
|
|
120
|
+
for (var i = 0; i < Res.AMAGDK_ADAPTERS.Length; i++)
|
|
121
|
+
{
|
|
122
|
+
var adapterName = Res.AMAGDK_ADAPTERS[i];
|
|
123
|
+
if (GUILayout.Button(ObjectNames.NicifyVariableName(adapterName)))
|
|
124
|
+
{
|
|
125
|
+
var package = $"{Res.PACKAGE_PATH}{adapterName}.unitypackage";
|
|
126
|
+
AssetDatabase.ImportPackage(package, false);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
static public Color btnColor;
|
|
132
|
+
static public float btnLerp;
|
|
133
|
+
void DrawGUI_ColorPicker()
|
|
134
|
+
{
|
|
135
|
+
GUILayout.BeginHorizontal();
|
|
136
|
+
{
|
|
137
|
+
btnColor = EditorGUILayout.ColorField(btnColor);
|
|
138
|
+
btnLerp = EditorGUILayout.Slider(btnLerp, -1f, 1f);
|
|
139
|
+
}
|
|
140
|
+
GUILayout.EndHorizontal();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public override void OnInspectorGUI()
|
|
144
|
+
{
|
|
145
|
+
if (sdk == null) return;
|
|
146
|
+
|
|
147
|
+
// DrawGUI_ColorPicker();
|
|
148
|
+
|
|
149
|
+
if (configAsset == null)
|
|
150
|
+
{
|
|
151
|
+
DrawGUI_ConfigMissing();
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
DrawGUI_AutoInit();
|
|
156
|
+
GUIToggleGroup("Config", ref showConfigDetail, DrawGUI_ConfigDetail, DrawGUI_ConfigAsset);
|
|
157
|
+
GUIToggleGroup("Adapters", ref showAdapterInstaller, DrawGUI_AdapterList);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
private static bool GUIButton(string label, float height = 16f, Color? color = null, float colorMod = 0.5f)
|
|
163
|
+
{
|
|
164
|
+
var bgColor = GUI.backgroundColor;
|
|
165
|
+
|
|
166
|
+
bool result;
|
|
167
|
+
if (color != null)
|
|
168
|
+
{
|
|
169
|
+
var c = (colorMod < 0f) ? Color.Lerp(color.Value, Color.black, -colorMod)
|
|
170
|
+
: (colorMod > 0f) ? Color.Lerp(color.Value, Color.white, colorMod) : color.Value;
|
|
171
|
+
GUI.backgroundColor = c;
|
|
172
|
+
}
|
|
173
|
+
{
|
|
174
|
+
result = GUILayout.Button(label, GUILayout.Height(height));
|
|
175
|
+
}
|
|
176
|
+
if (color != null) GUI.backgroundColor = bgColor;
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
private static bool GUIToggle(string label, ref bool value)
|
|
181
|
+
{
|
|
182
|
+
var newValue = EditorGUILayout.Toggle(label, value);
|
|
183
|
+
if (newValue == value) return false;
|
|
184
|
+
|
|
185
|
+
value = newValue;
|
|
186
|
+
EditorUtility.SetDirty(sdk);
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
private static bool GUIToggleGroup(string label, ref bool isOpen, Action drawFunc, Action titleFunc = null){
|
|
191
|
+
GUILayout.BeginHorizontal();
|
|
192
|
+
var newValue = EditorGUILayout.Foldout(isOpen, label);
|
|
193
|
+
var changed = newValue != isOpen;
|
|
194
|
+
titleFunc?.Invoke();
|
|
195
|
+
GUILayout.EndHorizontal();
|
|
196
|
+
|
|
197
|
+
if (isOpen)
|
|
198
|
+
{
|
|
199
|
+
EditorGUI.indentLevel++;
|
|
200
|
+
drawFunc();
|
|
201
|
+
EditorGUI.indentLevel--;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (!changed) return false;
|
|
205
|
+
|
|
206
|
+
isOpen = newValue;
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
package/Editor.meta
ADDED
package/LICENSE.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright © 2023 Amanotes ("**_Amanotes_**")
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/LICENSE.md.meta
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/Packages.meta
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Amanotes GDK
|
|
2
|
+
|
|
3
|
+
### Before you begin
|
|
4
|
+
|
|
5
|
+
AmaGDK is a free library from Amanotes provides classes, interfaces and adapter packages for Unity game development.
|
|
6
|
+
|
|
7
|
+
# Amanotes GDK for your game
|
|
8
|
+
|
|
9
|
+
# Getting started with AmaGDK
|
|
10
|
+
|
|
11
|
+
### Add AmaGDK prefab to your bootstrap scene (the first scene in your game build settings)
|
|
12
|
+
There are two ways to do:
|
|
13
|
+
1. Drag and drop the `AmaGDK` prefab from `Packages/AmaGDK/Runtime` to the hierachy window
|
|
14
|
+
2. Right click on the hierachy window, find and click `AmaGDK` to add it to the scene
|
|
15
|
+
|
|
16
|
+
### Usage
|
|
17
|
+
|
|
18
|
+
#### Import namespace
|
|
19
|
+
```
|
|
20
|
+
using Amanotes.Core;
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Get your service
|
|
24
|
+
Each service is a subclass of AmaGDK class. For example, logging event is an activity of analytics. We do:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
using Amanotes.Core;
|
|
28
|
+
|
|
29
|
+
public class YourGameSceneController
|
|
30
|
+
{
|
|
31
|
+
void DemoLogging()
|
|
32
|
+
{
|
|
33
|
+
AmaGDK.Analytics.LogEvent("demo_event");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
# Versioning
|
|
39
|
+
|
|
40
|
+
We use [SemVer](http://semver.org/) for versioning.
|
|
41
|
+
|
|
42
|
+
# License
|
|
43
|
+
|
|
44
|
+
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
|
package/README.md.meta
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
|
|
4
|
+
using ConfigAsset = Amanotes.Core.Internal.ConfigAsset;
|
|
5
|
+
using Status = Amanotes.Core.Internal.Status;
|
|
6
|
+
using static Amanotes.Core.Internal.Logging;
|
|
7
|
+
using static Amanotes.Core.Internal.Messsage;
|
|
8
|
+
|
|
9
|
+
namespace Amanotes.Core.Internal
|
|
10
|
+
{
|
|
11
|
+
public interface IAdapter
|
|
12
|
+
{
|
|
13
|
+
string Id { get; }
|
|
14
|
+
bool IsReady { get; }
|
|
15
|
+
void Init();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public class AdapterT<T> : IAdapter where T : IAdapter, new()
|
|
19
|
+
{
|
|
20
|
+
protected static T _instance;
|
|
21
|
+
protected static Status _status = Status.None;
|
|
22
|
+
public bool IsReady => _status == Status.Ready;
|
|
23
|
+
public string Id => typeof(T).ToString();
|
|
24
|
+
|
|
25
|
+
public void Init()
|
|
26
|
+
{
|
|
27
|
+
if (_status != Status.None)
|
|
28
|
+
{
|
|
29
|
+
LogWarning($"Invalid status: {_status}");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
_status = Status.Initialize;
|
|
34
|
+
InternalInit((success) =>
|
|
35
|
+
{
|
|
36
|
+
_status = success ? Status.Ready : Status.Failed;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
protected virtual void InternalInit(Action<bool> onCompleted)
|
|
41
|
+
{
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|