com.amanotes.gdk 0.2.49 → 0.2.51

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.
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 7f55e6986cd4437685e4bff21bf6ae7a
3
+ timeCreated: 1706774721
@@ -0,0 +1,158 @@
1
+ using System.Collections.Generic;
2
+ using UnityEditor;
3
+ using UnityEngine;
4
+ using System.Linq;
5
+ using UnityEditor.SceneManagement;
6
+
7
+ namespace Amanotes
8
+ {
9
+ internal class GDKProjectCP : EditorWindow
10
+ {
11
+ private static GDKProjectCP _window;
12
+ static Texture2D iconScene;
13
+ static Texture2D iconPlay;
14
+ static Texture2D iconFolder;
15
+ static GUIStyle productNameStyle;
16
+ static string projectPath;
17
+
18
+ private static int activeSceneIndex;
19
+
20
+
21
+ [MenuItem("Window/AmaGDK/Project Control Panel")]
22
+ private static void ShowWindow()
23
+ {
24
+ if (_window != null) return;
25
+
26
+ iconScene = AssetPreview.GetMiniTypeThumbnail(typeof(SceneAsset));
27
+ _window = CreateInstance<GDKProjectCP>();
28
+ _window.titleContent = new GUIContent("Project CP", iconScene, "GDK Project Control Panel");
29
+ _window.Show();
30
+ }
31
+
32
+ void Init()
33
+ {
34
+ if (iconScene == null) iconScene = AssetPreview.GetMiniTypeThumbnail(typeof(SceneAsset));
35
+ iconPlay = EditorGUIUtility.FindTexture("PlayButton");
36
+ iconFolder = EditorGUIUtility.FindTexture("Folder Icon");
37
+
38
+
39
+ productNameStyle = new GUIStyle(EditorStyles.largeLabel)
40
+ {
41
+ alignment = TextAnchor.MiddleCenter,
42
+ fontSize = 32
43
+ };
44
+
45
+ projectPath = Application.dataPath;
46
+ List<string> arr = projectPath.Split('/').ToList();
47
+ arr.RemoveAt(arr.Count - 1);
48
+
49
+ if (arr.Count > 3)
50
+ {
51
+ arr.RemoveRange(0, arr.Count - 3);
52
+ }
53
+
54
+ projectPath = string.Join("/", arr);
55
+ }
56
+
57
+ static void DrawBigPlayButton()
58
+ {
59
+ EditorBuildSettingsScene[] scenes = EditorBuildSettings.scenes;
60
+ if (scenes.Length == 0)
61
+ {
62
+ EditorGUILayout.HelpBox("No scene in Build Setting!", MessageType.Warning);
63
+ return;
64
+ }
65
+
66
+ EditorBuildSettingsScene scene = scenes[activeSceneIndex];
67
+
68
+ GUILayout.BeginHorizontal();
69
+ {
70
+ EditorGUILayout.Space();
71
+ GUILayout.BeginVertical();
72
+ {
73
+ GUILayout.Space(16);
74
+ GUILayout.Label(scene.path);
75
+ activeSceneIndex = EditorGUILayout.IntSlider(activeSceneIndex, 0, scenes.Length - 1);
76
+ }
77
+ GUILayout.EndVertical();
78
+ if (GUILayout.Button(iconPlay, GUILayout.Width(64f), GUILayout.Height(64f)))
79
+ {
80
+ OpenScene(scene.path, true);
81
+ }
82
+ }
83
+ GUILayout.EndHorizontal();
84
+ }
85
+
86
+ static void OpenScene(string scenePath, bool play)
87
+ {
88
+ if (EditorApplication.isPlaying)
89
+ {
90
+ EditorApplication.isPlaying = false;
91
+ }
92
+ else
93
+ {
94
+ EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
95
+ EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Single);
96
+ if (play) EditorApplication.isPlaying = true;
97
+ }
98
+ }
99
+
100
+ static void DrawProjectInfo()
101
+ {
102
+ GUILayout.Label(PlayerSettings.productName, productNameStyle);
103
+
104
+ var projectPathContent = new GUIContent(projectPath, iconFolder, "click to open folder");
105
+
106
+ if (GUILayout.Button(projectPathContent, EditorStyles.toolbarButton))
107
+ {
108
+ EditorUtility.RevealInFinder(Application.dataPath);
109
+ }
110
+ }
111
+
112
+ static void DrawListScenes()
113
+ {
114
+ EditorBuildSettingsScene[] listScenes = EditorBuildSettings.scenes;
115
+ int n = Mathf.Min(listScenes.Length, listScenes.Length);
116
+
117
+ GUILayout.BeginVertical();
118
+ {
119
+ for (var i = 0; i < n; i++)
120
+ {
121
+ EditorBuildSettingsScene scene = listScenes[i];
122
+ if (!scene.enabled) continue;
123
+
124
+ GUILayout.BeginHorizontal();
125
+ {
126
+ var asset = AssetDatabase.LoadAssetAtPath<SceneAsset>(scene.path);
127
+
128
+ if (GUILayout.Button(iconScene, EditorStyles.toolbarButton, GUILayout.Width(25f)))
129
+ {
130
+ OpenScene(scene.path, false);
131
+ }
132
+
133
+ EditorGUILayout.ObjectField(asset, typeof(SceneAsset), false);
134
+
135
+ if (GUILayout.Button(iconPlay, EditorStyles.toolbarButton, GUILayout.Width(25f)))
136
+ {
137
+ OpenScene(scene.path, true);
138
+ }
139
+ }
140
+ GUILayout.EndHorizontal();
141
+ }
142
+ }
143
+ GUILayout.EndVertical();
144
+ }
145
+
146
+
147
+ public void OnGUI()
148
+ {
149
+ if (productNameStyle == null) Init();
150
+
151
+ DrawProjectInfo();
152
+ EditorGUILayout.Space();
153
+ DrawBigPlayButton();
154
+ EditorGUILayout.Space();
155
+ DrawListScenes();
156
+ }
157
+ }
158
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 70d037b23c02e47d2a3c9b3a6606106a
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: 79b0d0152df1c40c98d5c8fd247ecdee
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
Binary file
@@ -1,5 +1,5 @@
1
1
  fileFormatVersion: 2
2
- guid: 26e42be832082494fb3eb94a4d9cd300
2
+ guid: e331d1b8f5c1d49bc8ef6ea5239e4ca4
3
3
  DefaultImporter:
4
4
  externalObjects: {}
5
5
  userData:
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 9de8b88fa236d49ecb6065f03cc91fc1
3
+ DefaultImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
Binary file
Binary file
Binary file
@@ -13,7 +13,7 @@ namespace Amanotes.Core.Internal
13
13
  [HideInInspector] [SerializeField] internal bool enabled = true;
14
14
  [NonSerialized] internal string adapterId;
15
15
  [NonSerialized] internal string adapterVersion;
16
- [NonSerialized] internal protected Status status = Status.None;
16
+ [NonSerialized] protected internal Status status = Status.None;
17
17
 
18
18
  protected abstract void Init(Action<bool> onComplete);
19
19
 
@@ -196,11 +196,11 @@ namespace Amanotes.Core
196
196
  // internal use
197
197
  internal static readonly AdsData localData = new AdsData().LoadJsonFromFile();
198
198
 
199
- internal protected static AdShowContext context;
200
- internal protected static AdAdapter _adapter;
201
- internal protected static float _savedVolume = -1;
202
- internal protected static float _savedTimeScale = -1;
203
-
199
+ protected internal static AdShowContext context;
200
+ protected internal static AdAdapter _adapter;
201
+ protected internal static float _savedVolume = -1;
202
+ protected internal static float _savedTimeScale = -1;
203
+
204
204
  public static void OnInter_Request(Action callback)
205
205
  {
206
206
  dispatcher.AddListener(Event.INTER_REQUEST, callback, false);
@@ -258,8 +258,8 @@ namespace Amanotes.Core
258
258
  }
259
259
  }
260
260
 
261
- public static bool HasInterstitial => _adapter.interstitial.hasAd;
262
- public static bool HasRewardedVideo => _adapter.rewardVideo.hasAd;
261
+ public static bool HasInterstitial => _adapter?.interstitial.hasAd ?? false;
262
+ public static bool HasRewardedVideo => _adapter?.rewardVideo.hasAd ?? false;
263
263
  public static bool IsBannerShowing => _isBannerShowing;
264
264
  public static bool IsAdShowing => context != null;
265
265
 
@@ -273,6 +273,7 @@ namespace Amanotes.Core
273
273
 
274
274
  public static IAdCallback ShowInterstitial(string placementName = null, Dictionary<string, object> userData = null)
275
275
  {
276
+ if (_adapter == null) return null;
276
277
  if (!ClearPrevContext()) return null;
277
278
 
278
279
  context = new AdShowContext(AdType.Interstitial, placementName, userData);
@@ -284,6 +285,7 @@ namespace Amanotes.Core
284
285
 
285
286
  public static IAdCallback ShowRewardedVideo(string placementName = null, Dictionary<string, object> userData = null)
286
287
  {
288
+ if (_adapter == null) return null;
287
289
  if (!ClearPrevContext()) return null;
288
290
 
289
291
  context = new AdShowContext(AdType.VideoReward, placementName, userData);
@@ -303,12 +305,8 @@ namespace Amanotes.Core
303
305
  _isBannerShowing = true;
304
306
  _showingBannerPosition = bannerPosition ?? Config.ad.bannerPosition;
305
307
 
306
- if (_adapter == null)
307
- {
308
- return;
309
- }
310
-
311
-
308
+ if (_adapter == null) return;
309
+
312
310
  dispatcher.Dispatch(Event.BANNER_SHOW);
313
311
  _adapter.ShowBanner(_showingBannerPosition);
314
312
  }
@@ -317,11 +315,13 @@ namespace Amanotes.Core
317
315
  {
318
316
  if (!_isBannerShowing) return;
319
317
  _isBannerShowing = false;
318
+ if (_adapter == null) return;
320
319
  _adapter.HideBanner();
321
320
  }
322
321
 
323
322
  public static void StopWaitForAd()
324
323
  {
324
+ if (_adapter == null) return;
325
325
  if (context == null)
326
326
  return;
327
327
 
@@ -357,6 +357,7 @@ namespace Amanotes.Core
357
357
 
358
358
  public static void SetUserId(string userId)
359
359
  {
360
+ if (_adapter == null) return;
360
361
  _adapter.SetUserId(userId);
361
362
  }
362
363
  }
@@ -373,6 +374,7 @@ namespace Amanotes.Core.Internal
373
374
  public int adShowTimeoutInSecs = 5;
374
375
  public BannerPosition bannerPosition = BannerPosition.BOTTOM;
375
376
  public bool autoLogEvent = true;
377
+ public bool checkInternet = true;
376
378
 
377
379
  public bool enableInterstitial = true;
378
380
  public bool enableRewarded = true;
@@ -396,14 +398,14 @@ namespace Amanotes.Core.Internal
396
398
  protected AdModuleConfig moduleConfig => Config.ad;
397
399
 
398
400
  // APIs
399
- internal protected abstract AdLogic interstitial { get; }
400
- internal protected abstract AdLogic rewardVideo { get; }
401
+ protected internal abstract AdLogic interstitial { get; }
402
+ protected internal abstract AdLogic rewardVideo { get; }
401
403
 
402
404
  public abstract void ShowBanner(BannerPosition bannerPosition);
403
405
  public abstract void HideBanner();
404
406
 
405
407
  // Internally used
406
- internal protected abstract void SetUserId(string userId);
408
+ protected internal abstract void SetUserId(string userId);
407
409
  }
408
410
 
409
411
  public interface IAdCallback { }
@@ -503,7 +505,6 @@ namespace Amanotes.Core.Internal
503
505
 
504
506
  public abstract class AdLogic
505
507
  {
506
- internal protected AdAdapter adapter => Ads._adapter;
507
508
  protected AdModuleConfig adConfig => Config.ad;
508
509
  protected AdShowContext context => Ads.context;
509
510
 
@@ -710,7 +711,7 @@ namespace Amanotes.Core.Internal
710
711
  if (_loadState != LoadAdsState.Requesting) StartLoadAd();
711
712
  var counter = 0;
712
713
  bool? hasInternet = null;
713
- _instance.StartCoroutine(WebUtils.CheckInternet(result => hasInternet = result));
714
+ if (adConfig.checkInternet) _instance.StartCoroutine(WebUtils.CheckInternet(result => hasInternet = result));
714
715
 
715
716
  var wait1Sec = new WaitForSecondsRealtime(1f);
716
717
  while (counter < timeout || timeout == -1)
@@ -719,7 +720,7 @@ namespace Amanotes.Core.Internal
719
720
  counter++;
720
721
 
721
722
  // finish checking internet & result is false
722
- if (hasInternet == false)
723
+ if (adConfig.checkInternet && hasInternet == false)
723
724
  {
724
725
  Log("[Ad] Stop WaitForAd : No internet!");
725
726
  _showState = ShowAdsState.ShowFail;