File tree Expand file tree Collapse file tree 4 files changed +41
-17
lines changed Expand file tree Collapse file tree 4 files changed +41
-17
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ public class AdSettingsEditor : Editor
8
8
{
9
9
private AdSettings _adSettings ;
10
10
private SerializedProperty _runtimeAutoInit ;
11
+ private SerializedProperty _runtimeAutoInitType ;
11
12
private SerializedProperty _adCheckingInterval ;
12
13
private SerializedProperty _adLoadingInterval ;
13
14
private SerializedProperty _adNetwork ;
@@ -41,6 +42,7 @@ void Initialize()
41
42
{
42
43
_adSettings = target as AdSettings ;
43
44
_runtimeAutoInit = serializedObject . FindProperty ( "runtimeAutoInit" ) ;
45
+ _runtimeAutoInitType = serializedObject . FindProperty ( "runtimeAutoInitType" ) ;
44
46
_adCheckingInterval = serializedObject . FindProperty ( "adCheckingInterval" ) ;
45
47
_adLoadingInterval = serializedObject . FindProperty ( "adLoadingInterval" ) ;
46
48
_adNetwork = serializedObject . FindProperty ( "adNetwork" ) ;
@@ -76,6 +78,12 @@ public override void OnInspectorGUI()
76
78
GuiLine ( 2 ) ;
77
79
GUILayout . Space ( 10 ) ;
78
80
EditorGUILayout . PropertyField ( _runtimeAutoInit ) ;
81
+ if ( _runtimeAutoInit . boolValue )
82
+ {
83
+ EditorGUILayout . PropertyField ( _runtimeAutoInitType ) ;
84
+ }
85
+
86
+ GUILayout . Space ( 10 ) ;
79
87
EditorGUILayout . PropertyField ( _adCheckingInterval ) ;
80
88
EditorGUILayout . PropertyField ( _adLoadingInterval ) ;
81
89
EditorGUILayout . PropertyField ( _adNetwork ) ;
Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using UnityEngine ;
4
+ using VirtueSky . Core ;
4
5
5
6
namespace VirtueSky . Ads
6
7
{
@@ -22,6 +23,7 @@ public static AdSettings Instance
22
23
}
23
24
24
25
[ SerializeField ] private bool runtimeAutoInit = true ;
26
+ [ SerializeField ] private CoreEnum . RuntimeAutoInitType runtimeAutoInitType ;
25
27
[ Range ( 5 , 100 ) , SerializeField ] private float adCheckingInterval = 8f ;
26
28
[ Range ( 5 , 100 ) , SerializeField ] private float adLoadingInterval = 15f ;
27
29
[ SerializeField ] private AdNetwork adNetwork = AdNetwork . Max ;
@@ -126,6 +128,7 @@ public string AppKey
126
128
127
129
128
130
public bool RuntimeAutoInit => runtimeAutoInit ;
131
+ public CoreEnum . RuntimeAutoInitType RuntimeAutoInitType => runtimeAutoInitType ;
129
132
public float AdCheckingInterval => adCheckingInterval ;
130
133
public float AdLoadingInterval => adLoadingInterval ;
131
134
Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using UnityEngine ;
3
+ using VirtueSky . Core ;
3
4
4
5
namespace VirtueSky . Ads
5
6
{
6
7
public static class AdStatic
7
8
{
9
+ #if VIRTUESKY_ADS
10
+ [ RuntimeInitializeOnLoadMethod ( RuntimeInitializeLoadType . BeforeSceneLoad ) ]
11
+ private static void RuntimeBeforeSceneLoad ( )
12
+ {
13
+ AutoInitialize ( CoreEnum . RuntimeAutoInitType . BeforeSceneLoad ) ;
14
+ }
15
+
16
+ [ RuntimeInitializeOnLoadMethod ( RuntimeInitializeLoadType . AfterSceneLoad ) ]
17
+ private static void RuntimeAfterSceneLoad ( )
18
+ {
19
+ AutoInitialize ( CoreEnum . RuntimeAutoInitType . AfterSceneLoad ) ;
20
+ }
21
+
22
+ private static void AutoInitialize ( CoreEnum . RuntimeAutoInitType adsRuntimeAutoInitType )
23
+ {
24
+ if ( AdSettings . Instance == null ) return ;
25
+ if ( ! AdSettings . Instance . RuntimeAutoInit ) return ;
26
+ if ( AdSettings . Instance . RuntimeAutoInitType != adsRuntimeAutoInitType ) return ;
27
+ var ads = new GameObject ( "Advertising" ) ;
28
+ ads . AddComponent < Advertising > ( ) ;
29
+ UnityEngine . Object . DontDestroyOnLoad ( ads ) ;
30
+ }
31
+
32
+ #endif
8
33
public static bool IsRemoveAd
9
34
{
10
35
#if VIRTUESKY_DATA
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ private void Start()
49
49
if ( adSettings . EnableGDPR )
50
50
{
51
51
#if VIRTUESKY_ADMOB
52
- InitGDPR ( ) ;
52
+ InitGdpr ( ) ;
53
53
#endif
54
54
}
55
55
else
@@ -143,9 +143,11 @@ void AutoLoadAppOpenAds()
143
143
#region Admob GDPR
144
144
145
145
#if VIRTUESKY_ADMOB
146
- private void InitGDPR ( )
146
+ private void InitGdpr ( )
147
147
{
148
- #if ! UNITY_EDITOR
148
+ #if UNITY_EDITOR
149
+ InitAdClient ( ) ;
150
+ #else
149
151
string deviceID = SystemInfo . deviceUniqueIdentifier ;
150
152
string deviceIDUpperCase = deviceID . ToUpper ( ) ;
151
153
@@ -236,20 +238,6 @@ private void ShowPrivacyOptionsForm()
236
238
237
239
#endregion
238
240
239
- #if VIRTUESKY_ADS
240
- [ RuntimeInitializeOnLoadMethod ( RuntimeInitializeLoadType . AfterSceneLoad ) ]
241
- private static void AutoInitialize ( )
242
- {
243
- if ( AdSettings . Instance == null ) return ;
244
- if ( AdSettings . Instance . RuntimeAutoInit )
245
- {
246
- var ads = new GameObject ( "Advertising" ) ;
247
- ads . AddComponent < Advertising > ( ) ;
248
- DontDestroyOnLoad ( ads ) ;
249
- }
250
- }
251
- #endif
252
-
253
241
254
242
#region Public API
255
243
You can’t perform that action at this time.
0 commit comments