1+ #if UNITY_EDITOR
2+ using System . Linq ;
3+ using UnityEditor ;
4+
5+ namespace VirtueSky . Ads
6+ {
7+ public class EditorScriptDefineSymbols : EditorWindow
8+ {
9+ #region Ads
10+
11+ private const string menuPathAds = "Sunflower/ScriptDefineSymbols/VIRTUESKY_ADS" ;
12+
13+ [ MenuItem ( menuPathAds ) ]
14+ public static void AdsConfigFlag ( )
15+ {
16+ SwitchFlag ( "VIRTUESKY_ADS" ) ;
17+ }
18+
19+ [ MenuItem ( menuPathAds , true ) ]
20+ public static bool IsAdsConfigFlagEnable ( )
21+ {
22+ Menu . SetChecked ( menuPathAds , IsFlagEnabled ( "VIRTUESKY_ADS" ) ) ;
23+ return true ;
24+ }
25+
26+ #endregion
27+
28+ #region Applovin
29+
30+ private const string menuPathApplovin = "Sunflower/ScriptDefineSymbols/ADS_APPLOVIN" ;
31+
32+ [ MenuItem ( menuPathApplovin ) ]
33+ public static void ApplovinConfigFlag ( )
34+ {
35+ SwitchFlag ( "ADS_APPLOVIN" ) ;
36+ }
37+
38+ [ MenuItem ( menuPathApplovin , true ) ]
39+ public static bool IsApplovinConfigFlagEnable ( )
40+ {
41+ Menu . SetChecked ( menuPathApplovin , IsFlagEnabled ( "ADS_APPLOVIN" ) ) ;
42+ return true ;
43+ }
44+
45+ #endregion
46+
47+ #region Admob
48+
49+ private const string menuPathAdmob = "Sunflower/ScriptDefineSymbols/ADS_ADMOB" ;
50+
51+ [ MenuItem ( menuPathAdmob ) ]
52+ public static void AdmobConfigFlag ( )
53+ {
54+ SwitchFlag ( "ADS_ADMOB" ) ;
55+ }
56+
57+ [ MenuItem ( menuPathAdmob , true ) ]
58+ public static bool IsAdmobConfigFlagEnable ( )
59+ {
60+ Menu . SetChecked ( menuPathAdmob , IsFlagEnabled ( "ADS_ADMOB" ) ) ;
61+ return true ;
62+ }
63+
64+ #endregion
65+
66+ #region Adjust
67+
68+ private const string menuPathAdjust = "Sunflower/ScriptDefineSymbols/VIRTUESKY_ADJUST" ;
69+
70+ [ MenuItem ( menuPathAdjust ) ]
71+ public static void AdjustConfigFlag ( )
72+ {
73+ SwitchFlag ( "VIRTUESKY_ADJUST" ) ;
74+ }
75+
76+ [ MenuItem ( menuPathAdjust , true ) ]
77+ public static bool IsAdjustConfigFlagEnable ( )
78+ {
79+ Menu . SetChecked ( menuPathAdjust , IsFlagEnabled ( "VIRTUESKY_ADJUST" ) ) ;
80+ return true ;
81+ }
82+
83+ #endregion
84+
85+ #region Firebase Analytics
86+
87+ private const string menuPathAnalytic = "Sunflower/ScriptDefineSymbols/VIRTUESKY_FIREBASE_ANALYTIC" ;
88+
89+ [ MenuItem ( menuPathAnalytic ) ]
90+ public static void AnalyticConfigFlag ( )
91+ {
92+ SwitchFlag ( "VIRTUESKY_FIREBASE_ANALYTIC" ) ;
93+ }
94+
95+ [ MenuItem ( menuPathAnalytic , true ) ]
96+ public static bool IsAnalyticConfigFlagEnable ( )
97+ {
98+ Menu . SetChecked ( menuPathAnalytic , IsFlagEnabled ( "VIRTUESKY_FIREBASE_ANALYTIC" ) ) ;
99+ return true ;
100+ }
101+
102+ #endregion
103+
104+ #region Base Functions
105+
106+ static void SwitchFlag ( string flag )
107+ {
108+ PlayerSettings . GetScriptingDefineSymbolsForGroup ( EditorUserBuildSettings . selectedBuildTargetGroup ,
109+ out var defines ) ;
110+ var enabled = defines . Contains ( flag ) ;
111+ defines = enabled ? defines . Where ( value => value != flag ) . ToArray ( ) : defines . Append ( flag ) . ToArray ( ) ;
112+ PlayerSettings . SetScriptingDefineSymbolsForGroup ( EditorUserBuildSettings . selectedBuildTargetGroup , defines ) ;
113+ }
114+
115+ static bool IsFlagEnabled ( string flag )
116+ {
117+ PlayerSettings . GetScriptingDefineSymbolsForGroup ( EditorUserBuildSettings . selectedBuildTargetGroup ,
118+ out var defines ) ;
119+ return defines . Contains ( flag ) ;
120+ }
121+
122+ #endregion
123+ }
124+ }
125+ #endif
0 commit comments