com.amanotes.gdk 0.2.75 → 0.2.77
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 +44 -0
- package/Editor/AmaGDKEditor.cs +24 -15
- package/Editor/Utils/GDKPackageInstaller.cs +116 -0
- package/Editor/Utils/GDKPackageInstaller.cs.meta +11 -0
- package/Extra/AmaGDKInstaller.unitypackage +0 -0
- package/Extra/AutoEventQC.unitypackage +0 -0
- package/{Runtime/GDKAudio/Plugins/iOS.meta → Extra/AutoEventQC.unitypackage.meta} +1 -2
- package/Extra/CheckDiskSpace.unitypackage +0 -0
- package/Extra/Consent.unitypackage +0 -0
- 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.AdRevenue.AF6.14AndOlder.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.AdQuality.unitypackage +0 -0
- package/{Runtime/GDKAudio/Plugins/macOS.meta → Packages/IronSourceAdapter.AdQuality.unitypackage.meta} +1 -2
- package/Packages/IronSourceAdapter.unitypackage +0 -0
- package/Packages/MaxAdNetworkAdapter.unitypackage +0 -0
- package/Packages/RevenueCatAdapter.unitypackage +0 -0
- package/Packages/SqliteAnalyticsAdapter.unitypackage +0 -0
- package/Runtime/Ad/AdLogic.cs +52 -55
- package/Runtime/Ad/AdShowContext.cs +1 -1
- package/Runtime/AmaGDK.Analytics.cs +18 -15
- package/Runtime/AmaGDK.Consent.cs +3 -8
- package/Runtime/AmaGDK.Mono.cs +1 -1
- package/Runtime/AmaGDK.RemoteConfig.cs +12 -2
- package/Runtime/AmaGDK.UserProfile.cs +31 -23
- package/Runtime/AmaGDK.cs +76 -40
- package/Runtime/Core/GDKDebug.cs +12 -5
- package/Runtime/Core/GDKPrefabPool.cs +571 -0
- package/Runtime/Core/GDKPrefabPool.cs.meta +11 -0
- package/Runtime/Core/GDKRoutine.cs +48 -2
- package/Runtime/Internal/AmaGDK.Internal.cs +1 -1
- package/Runtime/UI/ScrollView/Editor/GDKScrollViewEditor.cs +50 -0
- package/Runtime/UI/ScrollView/Editor/GDKScrollViewEditor.cs.meta +11 -0
- package/Runtime/{GDKAudio/Resources.meta → UI/ScrollView/Editor.meta} +1 -1
- package/Runtime/UI/ScrollView/GDKScrollView.cs +702 -0
- package/Runtime/UI/ScrollView/GDKScrollView.cs.meta +12 -0
- package/Runtime/UI/ScrollView.meta +9 -0
- package/Runtime/UI/ScrollableText/GDKScrollableText.cs +68 -0
- package/Runtime/UI/ScrollableText/GDKScrollableText.cs.meta +3 -0
- package/Runtime/UI/ScrollableText/GDKScrollableText.prefab +806 -0
- package/Runtime/UI/ScrollableText/GDKScrollableText.prefab.meta +7 -0
- package/Runtime/UI/ScrollableText.meta +3 -0
- package/Runtime/{GDKAudio/Plugins.meta → UI.meta} +1 -1
- package/Runtime/Utils/GDKUtils.cs +18 -0
- package/package.json +1 -1
- package/Packages/AppsFlyerAdapter.AdRevenue.unitypackage +0 -0
- package/Runtime/GDKAudio/GDKAudio.cs +0 -483
- package/Runtime/GDKAudio/GDKAudio.cs.meta +0 -3
- package/Runtime/GDKAudio/Plugins/Android/atensor-release.aar +0 -0
- package/Runtime/GDKAudio/Plugins/Android/atensor-release.aar.meta +0 -32
- package/Runtime/GDKAudio/Plugins/Android.meta +0 -3
- package/Runtime/GDKAudio/Plugins/iOS/libatensor.a +0 -0
- package/Runtime/GDKAudio/Plugins/iOS/libatensor.a.meta +0 -68
- package/Runtime/GDKAudio/Plugins/iOS/libcrypto.a +0 -0
- package/Runtime/GDKAudio/Plugins/iOS/libcrypto.a.meta +0 -68
- package/Runtime/GDKAudio/Plugins/iOS/libssl.a +0 -0
- package/Runtime/GDKAudio/Plugins/iOS/libssl.a.meta +0 -68
- package/Runtime/GDKAudio/Plugins/macOS/libatensor.dylib +0 -0
- package/Runtime/GDKAudio/Plugins/macOS/libatensor.dylib.meta +0 -81
- package/Runtime/GDKAudio/Resources/GDKAudioMixer.mixer +0 -133
- package/Runtime/GDKAudio/Resources/GDKAudioMixer.mixer.meta +0 -8
- package/Runtime/GDKAudio.meta +0 -3
- /package/Packages/{AppsFlyerAdapter.AdRevenue.unitypackage.meta → AppsFlyerAdapter.AdRevenue.AF6.14AndOlder.unitypackage.meta} +0 -0
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Linq;
|
|
4
|
+
|
|
5
|
+
namespace Amanotes.Core.Internal
|
|
6
|
+
{
|
|
7
|
+
public sealed class GDKPrefabPool : MonoBehaviour
|
|
8
|
+
{
|
|
9
|
+
public enum StartupPoolMode
|
|
10
|
+
{
|
|
11
|
+
Awake,
|
|
12
|
+
Start,
|
|
13
|
+
CallManually
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
[System.Serializable]
|
|
17
|
+
public class StartupPool
|
|
18
|
+
{
|
|
19
|
+
public int size;
|
|
20
|
+
public GameObject prefab;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private static GDKPrefabPool _instance;
|
|
24
|
+
private static readonly List<GameObject> tempList = new List<GameObject>();
|
|
25
|
+
|
|
26
|
+
private readonly Dictionary<GameObject, List<GameObject>> _pooledObjects = new Dictionary<GameObject, List<GameObject>>();
|
|
27
|
+
private readonly Dictionary<GameObject, GameObject> _spawnedObjects = new Dictionary<GameObject, GameObject>();
|
|
28
|
+
|
|
29
|
+
public StartupPoolMode startupPoolMode;
|
|
30
|
+
public StartupPool[] startupPools;
|
|
31
|
+
|
|
32
|
+
private bool _startupPoolsCreated;
|
|
33
|
+
|
|
34
|
+
void Awake()
|
|
35
|
+
{
|
|
36
|
+
if (_instance != null)
|
|
37
|
+
{
|
|
38
|
+
Destroy(this);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
_instance = this;
|
|
42
|
+
DontDestroyOnLoad(this);
|
|
43
|
+
if (startupPoolMode == StartupPoolMode.Awake)
|
|
44
|
+
CreateStartupPools();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
void Start()
|
|
48
|
+
{
|
|
49
|
+
if (startupPoolMode == StartupPoolMode.Start)
|
|
50
|
+
CreateStartupPools();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private static void CreateStartupPools()
|
|
54
|
+
{
|
|
55
|
+
if (instance._startupPoolsCreated)
|
|
56
|
+
return;
|
|
57
|
+
instance._startupPoolsCreated = true;
|
|
58
|
+
var pools = instance.startupPools;
|
|
59
|
+
if (pools == null || pools.Length <= 0)
|
|
60
|
+
return;
|
|
61
|
+
foreach (var t in pools)
|
|
62
|
+
CreatePool(t.prefab, t.size);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public static void CreatePool<T>(T prefab, int initialPoolSize) where T : Component
|
|
66
|
+
{
|
|
67
|
+
CreatePool(prefab.gameObject, initialPoolSize);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public static void CreatePool(GameObject prefab, int initialPoolSize)
|
|
71
|
+
{
|
|
72
|
+
if (prefab == null || instance._pooledObjects.ContainsKey(prefab))
|
|
73
|
+
return;
|
|
74
|
+
var list = new List<GameObject>();
|
|
75
|
+
instance._pooledObjects.Add(prefab, list);
|
|
76
|
+
|
|
77
|
+
if (initialPoolSize <= 0)
|
|
78
|
+
return;
|
|
79
|
+
bool active = prefab.activeSelf;
|
|
80
|
+
prefab.SetActive(false);
|
|
81
|
+
Transform parent = instance.transform;
|
|
82
|
+
while (list.Count < initialPoolSize)
|
|
83
|
+
{
|
|
84
|
+
var obj = Instantiate(prefab, parent, true);
|
|
85
|
+
list.Add(obj);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
prefab.SetActive(active);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public static T Spawn<T>(T prefab, Transform parent, Vector3 position, Quaternion rotation) where T : Component
|
|
92
|
+
{
|
|
93
|
+
return Spawn(prefab.gameObject, parent, position, rotation).GetComponent<T>();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public static T Spawn<T>(T prefab, Vector3 position, Quaternion rotation) where T : Component
|
|
97
|
+
{
|
|
98
|
+
return Spawn(prefab.gameObject, null, position, rotation).GetComponent<T>();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public static T Spawn<T>(T prefab, Transform parent, Vector3 position) where T : Component
|
|
102
|
+
{
|
|
103
|
+
return Spawn(prefab.gameObject, parent, position, Quaternion.identity).GetComponent<T>();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
public static T Spawn<T>(T prefab, Vector3 position) where T : Component
|
|
107
|
+
{
|
|
108
|
+
return Spawn(prefab.gameObject, null, position, Quaternion.identity).GetComponent<T>();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
public static T Spawn<T>(T prefab, Transform parent) where T : Component
|
|
112
|
+
{
|
|
113
|
+
return Spawn(prefab.gameObject, parent, Vector3.zero, Quaternion.identity).GetComponent<T>();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
public static T Spawn<T>(T prefab) where T : Component
|
|
117
|
+
{
|
|
118
|
+
return Spawn(prefab.gameObject, null, Vector3.zero, Quaternion.identity).GetComponent<T>();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public static GameObject Spawn(GameObject prefab, Transform parent, Vector3 position, Quaternion rotation)
|
|
122
|
+
{
|
|
123
|
+
Transform trans;
|
|
124
|
+
GameObject obj;
|
|
125
|
+
if (instance._pooledObjects.TryGetValue(prefab, out var list))
|
|
126
|
+
{
|
|
127
|
+
obj = null;
|
|
128
|
+
if (list.Count > 0)
|
|
129
|
+
{
|
|
130
|
+
while (obj == null && list.Count > 0)
|
|
131
|
+
{
|
|
132
|
+
obj = list[0];
|
|
133
|
+
list.RemoveAt(0);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (obj != null)
|
|
137
|
+
{
|
|
138
|
+
trans = obj.transform;
|
|
139
|
+
trans.SetParent(parent);
|
|
140
|
+
trans.localScale = prefab.transform.localScale;
|
|
141
|
+
trans.localPosition = position;
|
|
142
|
+
trans.localRotation = rotation;
|
|
143
|
+
obj.SetActive(true);
|
|
144
|
+
instance._spawnedObjects.Add(obj, prefab);
|
|
145
|
+
return obj;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
obj = Instantiate(prefab);
|
|
150
|
+
trans = obj.transform;
|
|
151
|
+
trans.SetParent(parent);
|
|
152
|
+
trans.localScale = prefab.transform.localScale;
|
|
153
|
+
trans.localPosition = position;
|
|
154
|
+
trans.localRotation = rotation;
|
|
155
|
+
instance._spawnedObjects.Add(obj, prefab);
|
|
156
|
+
return obj;
|
|
157
|
+
}
|
|
158
|
+
else
|
|
159
|
+
{
|
|
160
|
+
obj = Instantiate(prefab);
|
|
161
|
+
trans = obj.GetComponent<Transform>();
|
|
162
|
+
trans.SetParent(parent);
|
|
163
|
+
trans.localScale = prefab.transform.localScale;
|
|
164
|
+
trans.localPosition = position;
|
|
165
|
+
trans.localRotation = rotation;
|
|
166
|
+
return obj;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
public static GameObject Spawn(GameObject prefab, Transform parent, Vector3 position)
|
|
171
|
+
{
|
|
172
|
+
return Spawn(prefab, parent, position, Quaternion.identity);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
public static GameObject Spawn(GameObject prefab, Vector3 position, Quaternion rotation)
|
|
176
|
+
{
|
|
177
|
+
return Spawn(prefab, null, position, rotation);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
public static GameObject Spawn(GameObject prefab, Transform parent)
|
|
181
|
+
{
|
|
182
|
+
return Spawn(prefab, parent, Vector3.zero, Quaternion.identity);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
public static GameObject Spawn(GameObject prefab, Vector3 position)
|
|
186
|
+
{
|
|
187
|
+
return Spawn(prefab, null, position, Quaternion.identity);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
public static GameObject Spawn(GameObject prefab)
|
|
191
|
+
{
|
|
192
|
+
return Spawn(prefab, null, Vector3.zero, Quaternion.identity);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
public static void Recycle<T>(T obj) where T : Component
|
|
196
|
+
{
|
|
197
|
+
Recycle(obj.gameObject);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
public static void Recycle(GameObject obj)
|
|
201
|
+
{
|
|
202
|
+
if (instance._spawnedObjects.TryGetValue(obj, out var prefab))
|
|
203
|
+
Recycle(obj, prefab);
|
|
204
|
+
else
|
|
205
|
+
Destroy(obj);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
private static void Recycle(GameObject obj, GameObject prefab)
|
|
209
|
+
{
|
|
210
|
+
instance._pooledObjects[prefab].Add(obj);
|
|
211
|
+
instance._spawnedObjects.Remove(obj);
|
|
212
|
+
obj.transform.SetParent(instance.transform);
|
|
213
|
+
obj.SetActive(false);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
public static void RecycleAll<T>(T prefab) where T : Component
|
|
217
|
+
{
|
|
218
|
+
RecycleAll(prefab.gameObject);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
public static void RecycleAll(GameObject prefab)
|
|
222
|
+
{
|
|
223
|
+
foreach (var item in instance._spawnedObjects)
|
|
224
|
+
if (item.Value == prefab)
|
|
225
|
+
tempList.Add(item.Key);
|
|
226
|
+
foreach (var t in tempList)
|
|
227
|
+
Recycle(t);
|
|
228
|
+
tempList.Clear();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
public static void RecycleAll()
|
|
232
|
+
{
|
|
233
|
+
tempList.AddRange(instance._spawnedObjects.Keys);
|
|
234
|
+
foreach (var t in tempList)
|
|
235
|
+
Recycle(t);
|
|
236
|
+
tempList.Clear();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
public static bool IsSpawned(GameObject obj)
|
|
240
|
+
{
|
|
241
|
+
return instance._spawnedObjects.ContainsKey(obj);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
public static int CountPooled<T>(T prefab) where T : Component
|
|
245
|
+
{
|
|
246
|
+
return CountPooled(prefab.gameObject);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
public static int CountPooled(GameObject prefab)
|
|
250
|
+
{
|
|
251
|
+
if (instance._pooledObjects.TryGetValue(prefab, out var list))
|
|
252
|
+
return list.Count;
|
|
253
|
+
return 0;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
public static int CountSpawned<T>(T prefab) where T : Component
|
|
257
|
+
{
|
|
258
|
+
return CountSpawned(prefab.gameObject);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
public static int CountSpawned(GameObject prefab)
|
|
262
|
+
{
|
|
263
|
+
int count = 0;
|
|
264
|
+
foreach (var instancePrefab in instance._spawnedObjects.Values)
|
|
265
|
+
if (prefab == instancePrefab)
|
|
266
|
+
++count;
|
|
267
|
+
return count;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
public static int CountAllPooled()
|
|
271
|
+
{
|
|
272
|
+
return instance._pooledObjects.Values.Sum(list => list.Count);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
public static List<GameObject> GetPooled(GameObject prefab, List<GameObject> list, bool appendList)
|
|
276
|
+
{
|
|
277
|
+
list ??= new List<GameObject>();
|
|
278
|
+
if (!appendList)
|
|
279
|
+
list.Clear();
|
|
280
|
+
if (instance._pooledObjects.TryGetValue(prefab, out var pooled))
|
|
281
|
+
list.AddRange(pooled);
|
|
282
|
+
return list;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
public static List<T> GetPooled<T>(T prefab, List<T> list, bool appendList) where T : Component
|
|
286
|
+
{
|
|
287
|
+
list ??= new List<T>();
|
|
288
|
+
if (!appendList)
|
|
289
|
+
list.Clear();
|
|
290
|
+
if (!instance._pooledObjects.TryGetValue(prefab.gameObject, out var pooled))
|
|
291
|
+
return list;
|
|
292
|
+
list.AddRange(pooled.Select(t => t.GetComponent<T>()));
|
|
293
|
+
return list;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
public static List<GameObject> GetSpawned(GameObject prefab, List<GameObject> list, bool appendList)
|
|
297
|
+
{
|
|
298
|
+
list ??= new List<GameObject>();
|
|
299
|
+
if (!appendList)
|
|
300
|
+
list.Clear();
|
|
301
|
+
list.AddRange(from item in instance._spawnedObjects where item.Value == prefab select item.Key);
|
|
302
|
+
return list;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
public static List<T> GetSpawned<T>(T prefab, List<T> list, bool appendList) where T : Component
|
|
306
|
+
{
|
|
307
|
+
list ??= new List<T>();
|
|
308
|
+
if (!appendList)
|
|
309
|
+
list.Clear();
|
|
310
|
+
var prefabObj = prefab.gameObject;
|
|
311
|
+
foreach (var item in instance._spawnedObjects)
|
|
312
|
+
if (item.Value == prefabObj)
|
|
313
|
+
list.Add(item.Key.GetComponent<T>());
|
|
314
|
+
return list;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
public static void DestroyPooled(GameObject prefab)
|
|
318
|
+
{
|
|
319
|
+
if (!instance._pooledObjects.TryGetValue(prefab, out var pooled))
|
|
320
|
+
return;
|
|
321
|
+
foreach (var t in pooled)
|
|
322
|
+
Destroy(t);
|
|
323
|
+
pooled.Clear();
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
public static void DestroyPooled<T>(T prefab) where T : Component
|
|
327
|
+
{
|
|
328
|
+
DestroyPooled(prefab.gameObject);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
public static void DestroyAll(GameObject prefab)
|
|
332
|
+
{
|
|
333
|
+
RecycleAll(prefab);
|
|
334
|
+
DestroyPooled(prefab);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
public static void DestroyAll<T>(T prefab) where T : Component
|
|
338
|
+
{
|
|
339
|
+
DestroyAll(prefab.gameObject);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
public static GDKPrefabPool instance
|
|
343
|
+
{
|
|
344
|
+
get
|
|
345
|
+
{
|
|
346
|
+
if (_instance != null)
|
|
347
|
+
return _instance;
|
|
348
|
+
|
|
349
|
+
_instance = FindObjectOfType<GDKPrefabPool>();
|
|
350
|
+
if (_instance != null)
|
|
351
|
+
return _instance;
|
|
352
|
+
|
|
353
|
+
var obj = new GameObject("ObjectPool")
|
|
354
|
+
{
|
|
355
|
+
transform =
|
|
356
|
+
{
|
|
357
|
+
localPosition = Vector3.zero,
|
|
358
|
+
localRotation = Quaternion.identity,
|
|
359
|
+
localScale = Vector3.one
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
_instance = obj.AddComponent<GDKPrefabPool>();
|
|
363
|
+
return _instance;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
public static class ObjectPoolExtensions
|
|
369
|
+
{
|
|
370
|
+
public static void CreatePool<T>(this T prefab) where T : Component
|
|
371
|
+
{
|
|
372
|
+
GDKPrefabPool.CreatePool(prefab, 0);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
public static void CreatePool<T>(this T prefab, int initialPoolSize) where T : Component
|
|
376
|
+
{
|
|
377
|
+
GDKPrefabPool.CreatePool(prefab, initialPoolSize);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
public static void CreatePool(this GameObject prefab)
|
|
381
|
+
{
|
|
382
|
+
GDKPrefabPool.CreatePool(prefab, 0);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
public static void CreatePool(this GameObject prefab, int initialPoolSize)
|
|
386
|
+
{
|
|
387
|
+
GDKPrefabPool.CreatePool(prefab, initialPoolSize);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
public static T Spawn<T>(this T prefab, Transform parent, Vector3 position, Quaternion rotation)
|
|
391
|
+
where T : Component
|
|
392
|
+
{
|
|
393
|
+
return GDKPrefabPool.Spawn(prefab, parent, position, rotation);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
public static T Spawn<T>(this T prefab, Vector3 position, Quaternion rotation) where T : Component
|
|
397
|
+
{
|
|
398
|
+
return GDKPrefabPool.Spawn(prefab, null, position, rotation);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
public static T Spawn<T>(this T prefab, Transform parent, Vector3 position) where T : Component
|
|
402
|
+
{
|
|
403
|
+
return GDKPrefabPool.Spawn(prefab, parent, position, Quaternion.identity);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
public static T Spawn<T>(this T prefab, Vector3 position) where T : Component
|
|
407
|
+
{
|
|
408
|
+
return GDKPrefabPool.Spawn(prefab, null, position, Quaternion.identity);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
public static T Spawn<T>(this T prefab, Transform parent) where T : Component
|
|
412
|
+
{
|
|
413
|
+
return GDKPrefabPool.Spawn(prefab, parent, Vector3.zero, Quaternion.identity);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
public static T Spawn<T>(this T prefab) where T : Component
|
|
417
|
+
{
|
|
418
|
+
return GDKPrefabPool.Spawn(prefab, null, Vector3.zero, Quaternion.identity);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
public static GameObject Spawn(this GameObject prefab, Transform parent, Vector3 position, Quaternion rotation)
|
|
422
|
+
{
|
|
423
|
+
return GDKPrefabPool.Spawn(prefab, parent, position, rotation);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
public static GameObject Spawn(this GameObject prefab, Vector3 position, Quaternion rotation)
|
|
427
|
+
{
|
|
428
|
+
return GDKPrefabPool.Spawn(prefab, null, position, rotation);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
public static GameObject Spawn(this GameObject prefab, Transform parent, Vector3 position)
|
|
432
|
+
{
|
|
433
|
+
return GDKPrefabPool.Spawn(prefab, parent, position, Quaternion.identity);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
public static GameObject Spawn(this GameObject prefab, Vector3 position)
|
|
437
|
+
{
|
|
438
|
+
return GDKPrefabPool.Spawn(prefab, null, position, Quaternion.identity);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
public static GameObject Spawn(this GameObject prefab, Transform parent)
|
|
442
|
+
{
|
|
443
|
+
return GDKPrefabPool.Spawn(prefab, parent, Vector3.zero, Quaternion.identity);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
public static GameObject Spawn(this GameObject prefab)
|
|
447
|
+
{
|
|
448
|
+
return GDKPrefabPool.Spawn(prefab, null, Vector3.zero, Quaternion.identity);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
public static void Recycle<T>(this T obj) where T : Component
|
|
452
|
+
{
|
|
453
|
+
GDKPrefabPool.Recycle(obj);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
public static void Recycle(this GameObject obj)
|
|
457
|
+
{
|
|
458
|
+
GDKPrefabPool.Recycle(obj);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
public static void RecycleAll<T>(this T prefab) where T : Component
|
|
462
|
+
{
|
|
463
|
+
GDKPrefabPool.RecycleAll(prefab);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
public static void RecycleAll(this GameObject prefab)
|
|
467
|
+
{
|
|
468
|
+
GDKPrefabPool.RecycleAll(prefab);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
public static int CountPooled<T>(this T prefab) where T : Component
|
|
472
|
+
{
|
|
473
|
+
return GDKPrefabPool.CountPooled(prefab);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
public static int CountPooled(this GameObject prefab)
|
|
477
|
+
{
|
|
478
|
+
return GDKPrefabPool.CountPooled(prefab);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
public static int CountSpawned<T>(this T prefab) where T : Component
|
|
482
|
+
{
|
|
483
|
+
return GDKPrefabPool.CountSpawned(prefab);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
public static int CountSpawned(this GameObject prefab)
|
|
487
|
+
{
|
|
488
|
+
return GDKPrefabPool.CountSpawned(prefab);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
public static List<GameObject> GetSpawned(this GameObject prefab, List<GameObject> list, bool appendList)
|
|
492
|
+
{
|
|
493
|
+
return GDKPrefabPool.GetSpawned(prefab, list, appendList);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
public static List<GameObject> GetSpawned(this GameObject prefab, List<GameObject> list)
|
|
497
|
+
{
|
|
498
|
+
return GDKPrefabPool.GetSpawned(prefab, list, false);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
public static List<GameObject> GetSpawned(this GameObject prefab)
|
|
502
|
+
{
|
|
503
|
+
return GDKPrefabPool.GetSpawned(prefab, null, false);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
public static List<T> GetSpawned<T>(this T prefab, List<T> list, bool appendList) where T : Component
|
|
507
|
+
{
|
|
508
|
+
return GDKPrefabPool.GetSpawned(prefab, list, appendList);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
public static List<T> GetSpawned<T>(this T prefab, List<T> list) where T : Component
|
|
512
|
+
{
|
|
513
|
+
return GDKPrefabPool.GetSpawned(prefab, list, false);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
public static List<T> GetSpawned<T>(this T prefab) where T : Component
|
|
517
|
+
{
|
|
518
|
+
return GDKPrefabPool.GetSpawned(prefab, null, false);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
public static List<GameObject> GetPooled(this GameObject prefab, List<GameObject> list, bool appendList)
|
|
522
|
+
{
|
|
523
|
+
return GDKPrefabPool.GetPooled(prefab, list, appendList);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
public static List<GameObject> GetPooled(this GameObject prefab, List<GameObject> list)
|
|
527
|
+
{
|
|
528
|
+
return GDKPrefabPool.GetPooled(prefab, list, false);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
public static List<GameObject> GetPooled(this GameObject prefab)
|
|
532
|
+
{
|
|
533
|
+
return GDKPrefabPool.GetPooled(prefab, null, false);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
public static List<T> GetPooled<T>(this T prefab, List<T> list, bool appendList) where T : Component
|
|
537
|
+
{
|
|
538
|
+
return GDKPrefabPool.GetPooled(prefab, list, appendList);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
public static List<T> GetPooled<T>(this T prefab, List<T> list) where T : Component
|
|
542
|
+
{
|
|
543
|
+
return GDKPrefabPool.GetPooled(prefab, list, false);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
public static List<T> GetPooled<T>(this T prefab) where T : Component
|
|
547
|
+
{
|
|
548
|
+
return GDKPrefabPool.GetPooled(prefab, null, false);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
public static void DestroyPooled(this GameObject prefab)
|
|
552
|
+
{
|
|
553
|
+
GDKPrefabPool.DestroyPooled(prefab);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
public static void DestroyPooled<T>(this T prefab) where T : Component
|
|
557
|
+
{
|
|
558
|
+
GDKPrefabPool.DestroyPooled(prefab.gameObject);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
public static void DestroyAll(this GameObject prefab)
|
|
562
|
+
{
|
|
563
|
+
GDKPrefabPool.DestroyAll(prefab);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
public static void DestroyAll<T>(this T prefab) where T : Component
|
|
567
|
+
{
|
|
568
|
+
GDKPrefabPool.DestroyAll(prefab.gameObject);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
using System;
|
|
2
2
|
using System.Collections;
|
|
3
3
|
using UnityEngine;
|
|
4
|
+
using UnityEngine.Networking;
|
|
4
5
|
using static Amanotes.Core.GDKDebug;
|
|
5
6
|
|
|
6
7
|
namespace Amanotes.Core.Internal
|
|
@@ -76,13 +77,58 @@ namespace Amanotes.Core.Internal
|
|
|
76
77
|
public static GDKRoutine StartCoroutine(IEnumerator action)
|
|
77
78
|
{
|
|
78
79
|
var routine = new GDKRoutine(action);
|
|
79
|
-
|
|
80
|
+
if (isOnMainThread)
|
|
81
|
+
{
|
|
82
|
+
routine.StartRoutine();
|
|
83
|
+
}
|
|
84
|
+
else
|
|
85
|
+
{
|
|
86
|
+
DoOnMainThread(routine.StartRoutine);
|
|
87
|
+
}
|
|
88
|
+
|
|
80
89
|
return routine;
|
|
81
90
|
}
|
|
82
91
|
|
|
83
92
|
public static void StopCoroutine(GDKRoutine gdkRoutine)
|
|
84
93
|
{
|
|
85
|
-
|
|
94
|
+
if (gdkRoutine == null) return;
|
|
95
|
+
if (isOnMainThread)
|
|
96
|
+
{
|
|
97
|
+
gdkRoutine.StopRoutine();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
DoOnMainThread(gdkRoutine.StopRoutine);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public static void DownloadURL(string url, Action<string> onComplete, Action<string> onError = null)
|
|
105
|
+
{
|
|
106
|
+
StartCoroutine(RequestRoutine(url, onComplete, onError));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private static IEnumerator RequestRoutine(string url, Action<string> onComplete, Action<string> onError)
|
|
110
|
+
{
|
|
111
|
+
using UnityWebRequest webRequest = UnityWebRequest.Get(url);
|
|
112
|
+
UnityWebRequestAsyncOperation request = webRequest.SendWebRequest();
|
|
113
|
+
|
|
114
|
+
if (Application.isPlaying)
|
|
115
|
+
{
|
|
116
|
+
yield return request;
|
|
117
|
+
}
|
|
118
|
+
else // request can not be yield in Edit mode so yield it manually
|
|
119
|
+
{
|
|
120
|
+
while (!request.isDone) yield return null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (webRequest.result == UnityWebRequest.Result.Success)
|
|
124
|
+
{
|
|
125
|
+
SafeInvoke(onComplete, webRequest.downloadHandler.text);
|
|
126
|
+
yield break;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
LogWarning($"Download error <{url}>\n{webRequest.result}");
|
|
130
|
+
SafeInvoke(onError, webRequest.error);
|
|
131
|
+
SafeInvoke(onComplete, null);
|
|
86
132
|
}
|
|
87
133
|
}
|
|
88
134
|
}
|
|
@@ -46,7 +46,7 @@ namespace Amanotes.Core.Internal
|
|
|
46
46
|
#if UNITY_EDITOR
|
|
47
47
|
|
|
48
48
|
[MenuItem("GameObject/AmaGDK/Add AmaGDK Prefab", false, 10)]
|
|
49
|
-
|
|
49
|
+
public static void AddAmaGDKPrefab()
|
|
50
50
|
{
|
|
51
51
|
AssetDatabase.ImportPackage(Res.AMAGDK_CONFIG_PACKAGE, false);
|
|
52
52
|
var prefab = AssetDatabase.LoadAssetAtPath<GameObject>(AMAGDK_PREFAB);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#if UNITY_EDITOR
|
|
2
|
+
|
|
3
|
+
using Amanotes.Core.Internal;
|
|
4
|
+
using UnityEditor;
|
|
5
|
+
using UnityEditor.UI;
|
|
6
|
+
|
|
7
|
+
namespace Amanotes.Editor
|
|
8
|
+
{
|
|
9
|
+
[CustomEditor(typeof(GDKScrollView))]
|
|
10
|
+
public class GDKScrollViewEditor : ScrollRectEditor
|
|
11
|
+
{
|
|
12
|
+
private SerializedProperty _itemTemplate;
|
|
13
|
+
private SerializedProperty _defaultItemSize;
|
|
14
|
+
private SerializedProperty _layoutType;
|
|
15
|
+
|
|
16
|
+
public override void OnInspectorGUI()
|
|
17
|
+
{
|
|
18
|
+
serializedObject.Update();
|
|
19
|
+
|
|
20
|
+
EditorGUILayout.BeginVertical("box");
|
|
21
|
+
EditorGUILayout.Space(5);
|
|
22
|
+
DrawConfigInfo();
|
|
23
|
+
serializedObject.ApplyModifiedProperties();
|
|
24
|
+
EditorGUILayout.EndVertical();
|
|
25
|
+
|
|
26
|
+
EditorGUILayout.BeginVertical("box");
|
|
27
|
+
EditorGUILayout.Space(5);
|
|
28
|
+
base.OnInspectorGUI();
|
|
29
|
+
EditorGUILayout.EndVertical();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
protected override void OnEnable()
|
|
33
|
+
{
|
|
34
|
+
base.OnEnable();
|
|
35
|
+
_itemTemplate = serializedObject.FindProperty("itemTemplate");
|
|
36
|
+
_defaultItemSize = serializedObject.FindProperty("defaultItemSize");
|
|
37
|
+
_layoutType = serializedObject.FindProperty("layoutType");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private void DrawConfigInfo()
|
|
41
|
+
{
|
|
42
|
+
EditorGUILayout.PropertyField(_itemTemplate);
|
|
43
|
+
EditorGUILayout.PropertyField(_defaultItemSize);
|
|
44
|
+
_layoutType.intValue =
|
|
45
|
+
(int)(GDKScrollView.ItemLayoutType)EditorGUILayout.EnumPopup("layoutType",
|
|
46
|
+
(GDKScrollView.ItemLayoutType)_layoutType.intValue);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
#endif
|