2
2
using System ;
3
3
using UnityEngine ;
4
4
using UnityEditor ;
5
+ using UnityEditorInternal ;
5
6
6
7
namespace CAS . UEditor
7
8
{
@@ -19,10 +20,12 @@ internal class CASInitSettignsInspector : Editor
19
20
private SerializedProperty bannerSizeProp ;
20
21
private SerializedProperty locationUsageDescriptionProp ;
21
22
23
+ private ReorderableList managerIdsList ;
22
24
private BuildTarget platform ;
23
25
private bool promoDependencyExist ;
24
26
private bool teenDependencyExist ;
25
27
private bool generalDependencyExist ;
28
+ private bool reimportDependencyOnBuild ;
26
29
27
30
private int editorRuntimeActiveAdFlags ;
28
31
private Vector2 mediationNetworkScroll ;
@@ -58,7 +61,8 @@ private void OnEnable()
58
61
bannerSizeProp = props . FindProperty ( "bannerSize" ) ;
59
62
locationUsageDescriptionProp = props . FindProperty ( "locationUsageDescription" ) ;
60
63
61
- editorRuntimeActiveAdFlags = PlayerPrefs . GetInt ( CASEditorUtils . editorRuntomeActiveAdPrefs , - 1 ) ;
64
+ editorRuntimeActiveAdFlags = PlayerPrefs . GetInt ( CASEditorUtils . editorRuntimeActiveAdPrefs , - 1 ) ;
65
+ reimportDependencyOnBuild = PlayerPrefs . GetInt ( CASEditorUtils . editorReimportDepsOnBuildPrefs , 1 ) == 1 ;
62
66
63
67
string assetName = target . name ;
64
68
if ( assetName . EndsWith ( BuildTarget . Android . ToString ( ) ) )
@@ -71,15 +75,36 @@ private void OnEnable()
71
75
generalDependencyExist = CASEditorUtils . IsDependencyFileExists ( CASEditorUtils . generalTemplateDependency , platform ) ;
72
76
teenDependencyExist = CASEditorUtils . IsDependencyFileExists ( CASEditorUtils . teenTemplateDependency , platform ) ;
73
77
promoDependencyExist = CASEditorUtils . IsDependencyFileExists ( CASEditorUtils . promoTemplateDependency , platform ) ;
78
+
79
+ managerIdsList = new ReorderableList ( props , managerIdsProp , true , true , true , true )
80
+ {
81
+ drawHeaderCallback = DrawListHeader ,
82
+ drawElementCallback = DrawListElement
83
+ } ;
84
+ }
85
+
86
+ private void DrawListHeader ( Rect rect )
87
+ {
88
+ EditorGUI . LabelField ( rect , "Manager ID's" ) ;
74
89
}
75
90
91
+ private void DrawListElement ( Rect rect , int index , bool isActive , bool isFocused )
92
+ {
93
+ var item = managerIdsProp . GetArrayElementAtIndex ( index ) ;
94
+ rect . yMin += 1 ;
95
+ rect . yMax -= 1 ;
96
+ item . stringValue = EditorGUI . TextField ( rect , item . stringValue ) ;
97
+ }
98
+
99
+
76
100
public override void OnInspectorGUI ( )
77
101
{
78
102
var obj = serializedObject ;
79
103
obj . UpdateIfRequiredOrScript ( ) ;
80
104
EditorGUILayout . PropertyField ( testAdModeProp ) ;
81
105
EditorGUI . BeginDisabledGroup ( testAdModeProp . boolValue ) ;
82
- EditorGUILayout . PropertyField ( managerIdsProp , true ) ;
106
+ DrawSeparator ( ) ;
107
+ managerIdsList . DoLayoutList ( ) ;
83
108
OnManagerIDVerificationGUI ( ) ;
84
109
EditorGUI . EndDisabledGroup ( ) ;
85
110
@@ -104,7 +129,7 @@ public override void OnInspectorGUI()
104
129
DrawSeparator ( ) ;
105
130
interstitialIntervalProp . intValue = Math . Max ( 0 ,
106
131
EditorGUILayout . IntField ( "Interstitial impression interval(sec):" , interstitialIntervalProp . intValue ) ) ;
107
-
132
+
108
133
DrawSeparator ( ) ;
109
134
OnLoadingModeGUI ( ) ;
110
135
EditorGUILayout . PropertyField ( debugModeProp ) ;
@@ -116,6 +141,9 @@ public override void OnInspectorGUI()
116
141
DrawSeparator ( ) ;
117
142
OnAllowedAdNetworksGUI ( ) ;
118
143
144
+ DrawSeparator ( ) ;
145
+ OnBuildSettingsGUI ( ) ;
146
+
119
147
DrawSeparator ( ) ;
120
148
OnCASAboutGUI ( ) ;
121
149
obj . ApplyModifiedProperties ( ) ;
@@ -185,7 +213,7 @@ private bool OnAudienceGUIActiveChildren()
185
213
"Please use Android Resolver after the change." ,
186
214
MessageType . Error ) ;
187
215
if ( GUILayout . Button ( "Activate" , GUILayout . Height ( 38 ) ) )
188
- if ( ActivateDependencies ( CASEditorUtils . generalTemplateDependency ) )
216
+ if ( CASEditorUtils . TryActivateDependencies ( CASEditorUtils . generalTemplateDependency , platform ) )
189
217
generalDependencyExist = true ;
190
218
EditorGUILayout . EndHorizontal ( ) ;
191
219
}
@@ -226,7 +254,7 @@ private bool OnAudienceGUIActiveChildren()
226
254
" require Teen CAS Dependencies to be activated. " +
227
255
"Please use Android Resolver after the change." , MessageType . Error ) ;
228
256
if ( GUILayout . Button ( "Activate" , GUILayout . Height ( 38 ) ) )
229
- if ( ActivateDependencies ( CASEditorUtils . teenTemplateDependency ) )
257
+ if ( CASEditorUtils . TryActivateDependencies ( CASEditorUtils . teenTemplateDependency , platform ) )
230
258
teenDependencyExist = true ;
231
259
EditorGUILayout . EndHorizontal ( ) ;
232
260
}
@@ -334,7 +362,7 @@ private void OnLoadingModeGUI()
334
362
EditorGUI . EndDisabledGroup ( ) ;
335
363
}
336
364
337
- private static void DrawEffectiveSlider ( string label , float performVal )
365
+ private void DrawEffectiveSlider ( string label , float performVal )
338
366
{
339
367
EditorGUILayout . BeginHorizontal ( ) ;
340
368
GUILayout . Space ( 15.0f ) ;
@@ -354,11 +382,11 @@ private void OnEditroRuntimeActiveAdGUI()
354
382
editorRuntimeActiveAdFlags = Convert . ToInt32 (
355
383
EditorGUILayout . EnumFlagsField ( "Editor runtime Active ad" , ( AdFlags ) editorRuntimeActiveAdFlags ) ) ;
356
384
if ( EditorGUI . EndChangeCheck ( ) )
357
- PlayerPrefs . SetInt ( CASEditorUtils . editorRuntomeActiveAdPrefs , editorRuntimeActiveAdFlags ) ;
385
+ PlayerPrefs . SetInt ( CASEditorUtils . editorRuntimeActiveAdPrefs , editorRuntimeActiveAdFlags ) ;
358
386
}
359
387
}
360
388
361
- private static void OnCASAboutGUI ( )
389
+ private void OnCASAboutGUI ( )
362
390
{
363
391
EditorGUILayout . LabelField ( "CAS Unity wrapper version: " + MobileAds . wrapperVersion ) ;
364
392
EditorGUILayout . BeginHorizontal ( ) ;
@@ -382,24 +410,24 @@ private void OnPromoDependenciesGUI()
382
410
}
383
411
else
384
412
{
385
- if ( ActivateDependencies ( CASEditorUtils . promoTemplateDependency ) )
413
+ if ( CASEditorUtils . TryActivateDependencies ( CASEditorUtils . promoTemplateDependency , platform ) )
386
414
promoDependencyExist = true ;
387
415
}
388
416
}
389
- if ( platform == BuildTarget . Android )
417
+ if ( platform == BuildTarget . Android )
390
418
{
391
419
EditorGUI . indentLevel ++ ;
392
420
EditorGUILayout . HelpBox ( "Changing this flag will change the project dependencies. " +
393
421
"Please use Android Resolver after the change." , MessageType . None ) ;
394
422
EditorGUI . indentLevel -- ;
395
- }
423
+ }
396
424
}
397
425
398
426
private void OnAllowedAdNetworksGUI ( )
399
427
{
400
428
var audience = ( Audience ) audienceTaggedProp . enumValueIndex ;
401
429
mediationNetworkScroll = EditorGUILayout . BeginScrollView ( mediationNetworkScroll ,
402
- GUILayout . ExpandHeight ( false ) , GUILayout . MinHeight ( EditorGUIUtility . singleLineHeight * 5.5f ) ) ;
430
+ GUILayout . ExpandHeight ( false ) , GUILayout . MinHeight ( EditorGUIUtility . singleLineHeight * 5.5f ) ) ;
403
431
404
432
EditorGUILayout . LabelField ( "Allowed partners networks for " + audience . ToString ( ) + " audience" ) ;
405
433
EditorGUILayout . BeginHorizontal ( ) ;
@@ -435,19 +463,13 @@ private void OnAllowedAdNetworksGUI()
435
463
EditorGUILayout . EndScrollView ( ) ;
436
464
}
437
465
438
-
439
-
440
- private bool ActivateDependencies ( string template )
466
+ private void OnBuildSettingsGUI ( )
441
467
{
442
- CASEditorUtils . CreateFolderInAssets ( "Editor" ) ;
443
-
444
- string fromPath = CASEditorUtils . GetTemplatePath ( template + platform . ToString ( ) + ".xml" ) ;
445
- if ( string . IsNullOrEmpty ( fromPath ) )
446
- return false ;
447
-
448
- string dest = CASEditorUtils . editorFolderPath + "/"
449
- + template + platform . ToString ( ) + CASEditorUtils . dependenciesExtension ;
450
- return CASEditorUtils . TryCopyFile ( fromPath , dest ) ;
468
+ if ( reimportDependencyOnBuild != EditorGUILayout . ToggleLeft ( "Force reimport CAS dependencies on build." , reimportDependencyOnBuild ) )
469
+ {
470
+ reimportDependencyOnBuild = ! reimportDependencyOnBuild ;
471
+ PlayerPrefs . SetInt ( CASEditorUtils . editorReimportDepsOnBuildPrefs , reimportDependencyOnBuild ? 1 : 0 ) ;
472
+ }
451
473
}
452
474
453
475
private bool DeactivateDependencies ( string template )
@@ -456,7 +478,6 @@ private bool DeactivateDependencies( string template )
456
478
+ template + platform . ToString ( ) + CASEditorUtils . dependenciesExtension ) ;
457
479
}
458
480
459
-
460
481
private struct PartnerNetwork
461
482
{
462
483
public readonly string name ;
0 commit comments