Example #1
0
 // constructorと同じ役割
 private void OnEnable()
 {
     this.setting                 = UAdsSettingHelper.LoadOrCreateUAdsSettings();
     this.adcolonySymbol          = new ScriptDefineSymbol(groups, UAdsSettingHelper.ADCOLONY_DEFINE);
     this.unityMonetizationSymbol = new ScriptDefineSymbol(groups, UAdsSettingHelper.UNITY_MONETIZATION);
     this.enableAdColony          = this.adcolonySymbol.HasDefine();
     this.enableUnityMonetization = this.unityMonetizationSymbol.HasDefine();
 }
Example #2
0
        public void OnGUI()
        {
            // compile中は表示する.
            if (EditorApplication.isCompiling)
            {
                EditorGUILayout.LabelField("compiling...");
            }

            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                EditorGUILayout.LabelField("UnityAds");
                var tmpEnableMonetization = EditorGUILayout.ToggleLeft("Enable UnityMonetization", this.enableUnityMonetization);
                if (tmpEnableMonetization != enableUnityMonetization)
                {
                    this.enableUnityMonetization    = tmpEnableMonetization;
                    setting.enableUnityMonetization = enableUnityMonetization;
                    if (enableUnityMonetization)
                    {
                        this.unityMonetizationSymbol.SetDefine();
                    }
                    else
                    {
                        unityMonetizationSymbol.RemoveDefine();
                    }
                    // defineを変更したのでconmpileさせる
                    AssetDatabase.Refresh();
                }

#if UNITY_ADS || UNITY_MONETIZATION
                using (new EditorGUI.IndentLevelScope()) {
                    using (new EditorGUILayout.HorizontalScope()) {
                        EditorGUILayout.PrefixLabel("androidGameId");
                        setting.unityAds.androidGameId = EditorGUILayout.TextField(setting.unityAds.androidGameId);
                    }
                    using (new EditorGUILayout.HorizontalScope()) {
                        EditorGUILayout.PrefixLabel("iOSGameId");
                        setting.unityAds.iOSGameId = EditorGUILayout.TextField(setting.unityAds.iOSGameId);
                    }
                    using (new EditorGUILayout.HorizontalScope()) {
                        EditorGUILayout.PrefixLabel("rewardVideoZoneId");
                        setting.unityAds.rewardVideoPlacementId = EditorGUILayout.TextField(setting.unityAds.rewardVideoPlacementId);
                    }
                }
#endif
            }

            #region AdColony

            EditorGUILayout.Space();
            DisplayAdcolonyLayout(this.setting);
            #endregion

            using (new EditorGUILayout.HorizontalScope()) {
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Export"))
                {
                    var path = EditorUtility.SaveFilePanel("Export Json", Application.dataPath, "export_setting.json", "json");
                    UAdsSettingHelper.Export(path, JsonUtility.ToJson(setting));
                }
                if (GUILayout.Button("Import"))
                {
                    var path = EditorUtility.OpenFilePanel("Import Json", Application.dataPath, "json");
                    UAdsSettingHelper.Import(path, ref this.setting);
                    UAdsSettingHelper.SaveUAdsSettings(this.setting);
                }
                if (GUILayout.Button("Save"))
                {
                    UAdsSettingHelper.SaveUAdsSettings(setting);
                }
            }
        }
Example #3
0
        public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject)
        {
            if (target != BuildTarget.iOS)
            {
                return;
            }

            var plistPath = pathToBuiltProject + "/Info.plist";
            var plist     = new PlistDocument();

            plist.ReadFromString(File.ReadAllText(plistPath));

            // SKAdNetworkIdentifierのListを取得
            var xml = AssetDatabase.LoadAssetAtPath <TextAsset>("Assets/UAds/Editor/skadnetworks.plist.xml").text;
            var unityAdsSkAdNetworkItems = UnityAdsSKAdNetworkXmlParser.Parse(xml);
            var adcolonySkAdNetworkItems = new HashSet <string>()
            {
                // adcolony
                // https://support.adcolony.com/helpdesk/network-ids-for-skadnetwork-ios-only/
                "4pfyvq9l8r.skadnetwork",
                "yclnxrl5pm.skadnetwork",
                "v72qych5uu.skadnetwork",
                "tl55sbb4fm.skadnetwork",
                "t38b2kh725.skadnetwork",
                "prcb7njmu6.skadnetwork",
                "ppxm28t8ap.skadnetwork",
                "mlmmfzh3r3.skadnetwork",
                "klf5c3l5u5.skadnetwork",
                "hs6bdukanm.skadnetwork",
                "c6k4g5qg8m.skadnetwork",
                "9t245vhmpl.skadnetwork",
                "9rd848q2bz.skadnetwork",
                "8s468mfl3y.skadnetwork",
                "7ug5zh24hu.skadnetwork",
                "4fzdc2evr5.skadnetwork",
                "4468km3ulz.skadnetwork",
                "3rd42ekr43.skadnetwork",
                "2u9pt9hc89.skadnetwork",
                "m8dbw4sv7c.skadnetwork",
                "7rz58n8ntl.skadnetwork",
                "ejvt5qm6ak.skadnetwork",
                "5lm9lj6jb7.skadnetwork",
                "44jx6755aq.skadnetwork",
                "mtkv5xtk9e.skadnetwork",
            };

            // UAdsの設定を取得する
            var settings = UAdsSettingHelper.LoadOrCreateUAdsSettings();

            // 有効になっているものだけ追加するようにする
            var res = new HashSet <string>();

            if (settings.enableUnityMonetization)
            {
                res.UnionWith(unityAdsSkAdNetworkItems.Select(v => v.skAdNetworkIdentifier));
            }
            if (settings.enableAdcolony)
            {
                res.UnionWith(adcolonySkAdNetworkItems);
            }

            // plistに追加
            var rootDict = plist.root;
            var array    = rootDict.CreateArray("SKAdNetworkItems");

            foreach (var item in res)
            {
                var dic = array.AddDict();
                // 小文字じゃないとだめなそうなのでToLowerで小文字化.
                dic.SetString("SKAdNetworkIdentifier", item.ToLower());
            }
            File.WriteAllText(plistPath, plist.WriteToString());
        }