void Start() { GameObject.DontDestroyOnLoad(gameObject); // keep ad alive if we load a new scene banner = new ADBannerView(ADBannerView.Type.Banner,showOnTop ? ADBannerView.Layout.Top : ADBannerView.Layout.Bottom); ADBannerView.onBannerWasLoaded += OnBannerLoaded; }
void CreateBanner() { banner = new ADBannerView(); banner.autoSize = true; banner.autoPosition = ADPosition.Bottom; StartCoroutine(ShowBanner()); }
IEnumerator Start() { #if UNITY_IPHONE ADBannerView banner = new ADBannerView(); banner.autoSize = true; if(mPosition == AdBannerPosition.top) { banner.autoPosition = ADPosition.Top; } else { banner.autoPosition = ADPosition.Bottom; } while (true) { if (banner.error != null) { Debug.Log("Error: " + banner.error.description); break; } else if (banner.loaded) { banner.Show(); break; } yield return null; } #elif UNITY_ANDROID && !UNITY_EDITOR AndroidJavaClass plugin = new AndroidJavaClass("jp.radiumsoftware.unityplugin.admob.AdBannerController"); AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"); while (true) { plugin.CallStatic("tryCreateBanner", activity, mAdMobPublisherId, mAdMobTestDeviceId, mPosition.ToString()); yield return new WaitForSeconds(Mathf.Max(30.0f, mRefreshTime)); } #else return null; #endif }
IEnumerator Start() { #if UNITY_IPHONE ADBannerView banner = new ADBannerView(); banner.autoSize = true; banner.autoPosition = ADPosition.Bottom; while (true) { if (banner.error != null) { Debug.Log("Error: " + banner.error.description); break; } else if (banner.loaded) { banner.Show(); break; } yield return null; } #elif UNITY_ANDROID && !UNITY_EDITOR AndroidJavaClass plugin = new AndroidJavaClass("net.oira_project.adstirunityplugin.AdBannerController"); AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"); while (true) { plugin.CallStatic("tryCreateBanner", activity, mAdStirMediaId, mAdStirSpotId); yield return new WaitForSeconds(Mathf.Max(30.0f, mRefreshTime)); } #else return null; #endif }
IEnumerator Start() { #if UNITY_IPHONE ADBannerView banner = new ADBannerView(ADBannerView.Type.Banner,ADBannerView.Layout.Bottom); //banner.autoSize = true; //banner.autoPosition = ADPosition.Bottom; while (true) { if (banner.loaded) { banner.visible = true; break; } yield return null; } #elif UNITY_ANDROID && !UNITY_EDITOR AndroidJavaClass plugin = new AndroidJavaClass("jp.radiumsoftware.unityplugin.admob.AdBannerController"); AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity"); while (true) { plugin.CallStatic("tryCreateBanner", activity, mAdMobPublisherId, mAdMobTestDeviceId); yield return new WaitForSeconds(Mathf.Max(30.0f, mRefreshTime)); } #else return null; #endif }
void Awake() { if (GA_ADSUPPORT != null) { // only one ad support allowed per scene GA.LogWarning("Destroying dublicate GA_ADSUPPORT - only one is allowed per scene!"); Destroy(gameObject); return; } GA_ADSUPPORT = this; DontDestroyOnLoad(gameObject); if (GA.SettingsGA.Start_AlwaysShowAds) { EnableAds(); } SaveConditions (); // iAd if (GA.SettingsGA.IAD_enabled) { #if UNITY_IPHONE if (ADBannerView.IsAvailable(ADBannerView.Type.MediumRect) && iPhone.generation.ToString().StartsWith("iPad")) _iAdBanner = new ADBannerView(GA.SettingsGA.IAD_type, GA.SettingsGA.IAD_layout); else _iAdBanner = new ADBannerView(ADBannerView.Type.Banner, GA.SettingsGA.IAD_layout); if (GA.SettingsGA.IAD_layout == ADBannerView.Layout.Manual) { _iAdBanner.position = GA.SettingsGA.IAD_position; } ADBannerView.onBannerWasClicked += OnBannerClicked; ADBannerView.onBannerWasLoaded += OnBannerLoaded; #endif } // Charboost #if CB_ON if (GA.SettingsGA.CB_enabled) { GameObject go = new GameObject("ChartboostManager"); go.AddComponent<CBManager>(); #if UNITY_ANDROID CBBinding.init(); #elif UNITY_IPHONE CBBinding.init( GA.SettingsGA.CB_appID, GA.SettingsGA.CB_appSig ); #endif CBManager.didDismissInterstitialEvent += OnDismissInterstitialEvent; CBManager.didCloseInterstitialEvent += OnCloseInterstitialEvent; CBManager.didClickInterstitialEvent += OnClickInterstitialEvent; CBManager.didShowInterstitialEvent += OnShowInterstitialEvent; } #endif }
private IEnumerator ShowBanner() { while (!banner.loaded && banner.error == null) { yield return bannerStatus = "Loading... iAd banner"; } if (banner.error == null) banner.Show(); else { bannerStatus = banner.error.ToString(); banner = null; } }
private IEnumerator StartBanner() { if (dontDestroy) { GameObject.DontDestroyOnLoad(gameObject); // keep ad alive if we load a new scene } banner = new ADBannerView(); banner.autoSize = true; banner.autoPosition = showOnTop ? ADPosition.Top : ADPosition.Bottom; while (!banner.loaded && banner.error == null) { yield return null; } if (banner.error == null) { banner.Show(); } else { banner = null; } }
public static bool IsAvailable(ADBannerView.Type type) { return false; }
public ADBannerView(ADBannerView.Type type, ADBannerView.Layout layout) { }
void OnGUI() { Texture2D tex = (Texture2D)Resources.Load("heart"); for (int i=SackBehavior.GroundTouches; i<_lives; i++) { GUI.DrawTexture(new Rect (((_lives - 1) * 25) - (i * 25), 2, 25, 25), tex); } GUI.skin.font = UIFont; GUIStyle style = new GUIStyle (); style.fontSize = 30; style.normal.textColor = new Color (0.18f, 1f, 0f); GUI.Label(new Rect((Screen.width) - 40, 4, 20, 10), SackBehavior.Kicks.ToString(), style); if (SackBehavior.GroundTouches >= _lives || SackBehavior.OutOfScreen) { SackBehavior.Active = false; if (!_scoreReported) { Social.ReportScore(SackBehavior.Kicks, "HackyBallTotal", ProcessScoreReport); _scoreReported = true; } GUI.Box(new Rect(0, 0, Screen.width, Screen.height), _menuBackground, GUIStyle.none); float buttonY = (Screen.height / 2) - ((Screen.width / 6) / 2); Texture2D gameOverButton = (Texture2D)Resources.Load("GameOverButton"); GUI.Button(new Rect((Screen.width / 2) - ((Screen.width / 1.5f) / 2), buttonY - ((Screen.width / 6) * 0.5f), (Screen.width / 1.5f), (Screen.width / 6)), gameOverButton, GUIStyle.none); style.fontSize = 50; GUI.Label(new Rect((Screen.width) - (Screen.width / 2) - 120, buttonY + (Screen.width / 6) * 0.75f, 20, 10), "Score: " + SackBehavior.Kicks.ToString(), style); Texture2D mainButton = (Texture2D)Resources.Load("PlayButton"); if (GUI.Button(new Rect((Screen.width / 2) - ((Screen.width / 3) / 2), buttonY + ((Screen.width / 6) * 1.5f), (Screen.width / 3), (Screen.width / 6)), mainButton, GUIStyle.none)) { _restart = true; Time.timeScale = 1; Application.LoadLevel(0); } Texture2D scoreButton = (Texture2D)Resources.Load("ScoreButton"); if (GUI.Button(new Rect((Screen.width / 2) - ((Screen.width / 3) / 2), buttonY + ((Screen.width / 6) * 2.5f) + 5, (Screen.width / 3), (Screen.width / 6)), scoreButton, GUIStyle.none)) { Social.ShowLeaderboardUI(); } if (banner == null) { banner = new ADBannerView(ADBannerView.Type.Banner, ADBannerView.Layout.BottomCenter); } else banner.visible = true; } else if (Time.timeScale == 0) { GUI.Box(new Rect(0, 0, Screen.width, Screen.height), _menuBackground, GUIStyle.none); float buttonY = (Screen.height / 2) - ((Screen.width / 6) / 2); Texture2D mainButton = (Texture2D)Resources.Load("PlayButton"); if (GUI.Button(new Rect((Screen.width / 2) - ((Screen.width / 3) / 2), buttonY, (Screen.width / 3), (Screen.width / 6)), mainButton, GUIStyle.none)) { _restart = true; Time.timeScale = 1; Application.LoadLevel(0); } Texture2D scoreButton = (Texture2D)Resources.Load("ScoreButton"); if (GUI.Button(new Rect((Screen.width / 2) - ((Screen.width / 3) / 2), buttonY + (Screen.width / 6) + 5, (Screen.width / 3), (Screen.width / 6)), scoreButton, GUIStyle.none)) { Social.ShowLeaderboardUI(); } if (banner == null) { banner = new ADBannerView(ADBannerView.Type.Banner, ADBannerView.Layout.BottomCenter); ADBannerView.onBannerWasLoaded += OnBannerLoaded; } else banner.visible = true; } else if (banner != null) banner.visible = false; }
void Start() { banner = new ADBannerView(ADBannerView.Type.Banner, ADBannerView.Layout.Bottom); ADBannerView.onBannerWasClicked += OnBannerClicked; ADBannerView.onBannerWasLoaded += OnBannerLoaded; }