Skip to content

Commit 2ab1c61

Browse files
committed
update
1 parent 27f0aaa commit 2ab1c61

File tree

4 files changed

+144
-4
lines changed

4 files changed

+144
-4
lines changed
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
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

Editor/EditorScriptDefineSymbols.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
## Advertising for unity
22
(Supports applovin 5.11.3 and google admob 8.5.2)
3-
- built on scriptableobject architecture, you need to install [Sunflower](https://github.com/VirtueSky/sunflower) to use
43

54
# Use
65
- After installation, open Adsetting to set up AdUnit Id
76

8-
(Ctrl + E or GameControl -> adSetting to open Adsetting)
7+
(Ctrl + E or Sunflower (MenuItem) -> Ads to open Adsetting)
98

109
![OpenAdsetting](https://github.com/wolf-package/advertising/assets/126542083/fc1d053d-56cc-4126-a6db-6cf03a2a6b46)
1110
- You can choose Ad Network Applovin for Admob and click `Create` button to create AdUnitiVariable

VirtueSky.Ads.asmdef

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
11
{
2-
"name": "VirtueSky.Ads"
3-
}
2+
"name": "VirtueSky.Ads",
3+
"rootNamespace": "",
4+
"references": [
5+
"GUID:a4cfc1a18fa3a469b96d885db522f42e"
6+
],
7+
"includePlatforms": [],
8+
"excludePlatforms": [],
9+
"allowUnsafeCode": false,
10+
"overrideReferences": false,
11+
"precompiledReferences": [],
12+
"autoReferenced": true,
13+
"defineConstraints": [],
14+
"versionDefines": [],
15+
"noEngineReferences": false
16+
}

0 commit comments

Comments
 (0)