private void PhaseConfig(string config) { isLoad = true; string[] ary = config.Split('\n'); List <ADConfig> selfList = new List <ADConfig>(); foreach (string str in ary) { string[] ary2 = str.Split('\t'); if (ary2[0] == platform.ToString() && ary2.Length == 5) { ADConfig ad = new ADConfig(); ad.platfrom = platform; ad.image = ary2[1]; ad.url = ary2[2]; ad.start_show = int.Parse(ary2[3]); ad.admob_show = int.Parse(ary2[4]); if (ad.url.IndexOf("http") >= 0) { if (ad.start_show == 1)//内置广告 { selfList.Add(ad); } } else { admob_show = ad.admob_show == 1; } } } if (selfList.Count > 0) { selfAD = selfList[Random.Range(0, selfList.Count)]; if (selfAD.image.IndexOf("http") >= 0)//网络资源 { StartCoroutine(LoadImage(selfAD.image)); } else { Sprite img = Resources.Load("image/ad/" + selfAD.image.Split('.')[0], typeof(Sprite)) as Sprite; if (img) { transform.GetChild(0).gameObject.SetActive(true); transform.GetChild(0).GetComponent <Image>().sprite = img; } else { Debug.Log("image/ad/" + selfAD.image.Split('.')[0] + "load Error"); } } } else { Quit(); } #if UNITY_IOS && !UNITY_EDITOR if (UnityEngine.iOS.ADBannerView.IsAvailable(UnityEngine.iOS.ADBannerView.Type.Banner)) { bannerInventor = ADInventor.iad; } else { bannerInventor = ADInventor.admob; } if (UnityEngine.iOS.ADInterstitialAd.isAvailable) { interstitialInventor = ADInventor.iad; } else { interstitialInventor = ADInventor.admob; } #else bannerInventor = ADInventor.admob; interstitialInventor = ADInventor.admob; #endif }
private void PhaseConfig(string config) { isLoad = true; string[] ary = config.Split('\n'); List<ADConfig> selfList = new List<ADConfig>(); foreach (string str in ary) { string[] ary2 = str.Split('\t'); if (ary2[0] == platform.ToString() && ary2.Length == 5) { ADConfig ad = new ADConfig(); ad.platfrom = platform; ad.image = ary2[1]; ad.url = ary2[2]; ad.start_show = int.Parse(ary2[3]); ad.admob_show = int.Parse(ary2[4]); if (ad.url.IndexOf("http") >= 0) { if (ad.start_show == 1)//内置广告 selfList.Add(ad); } else admob_show = ad.admob_show == 1; } } if (selfList.Count > 0) { selfAD = selfList[Random.Range(0, selfList.Count)]; if (selfAD.image.IndexOf("http") >= 0)//网络资源 { StartCoroutine(LoadImage(selfAD.image)); } else { Sprite img = Resources.Load("image/ad/" + selfAD.image.Split('.')[0], typeof(Sprite)) as Sprite; if (img) { transform.GetChild(0).gameObject.SetActive(true); transform.GetChild(0).GetComponent<Image>().sprite = img; } else Debug.Log("image/ad/" + selfAD.image.Split('.')[0] + "load Error"); } } else Quit(); #if UNITY_IOS && !UNITY_EDITOR if(UnityEngine.iOS.ADBannerView.IsAvailable(UnityEngine.iOS.ADBannerView.Type.Banner)) bannerInventor = ADInventor.iad; else bannerInventor = ADInventor.admob; if(UnityEngine.iOS.ADInterstitialAd.isAvailable) interstitialInventor = ADInventor.iad; else interstitialInventor = ADInventor.admob; #else bannerInventor = ADInventor.admob; interstitialInventor = ADInventor.admob; #endif }