/// <summary> /// Adds a custom event to the submit queue (see GA_Queue) /// </summary> /// <param name="eventName"> /// Identifies the event so this should be as descriptive as possible. PickedUpAmmo might be a good event name. EventTwo is a bad event name! <see cref="System.String"/> /// </param> /// <param name="eventValue"> /// A value relevant to the event. F.x. if the player picks up some shotgun ammo the eventName could be "PickedUpAmmo" and this value could be "Shotgun". This can be null <see cref="System.Nullable<System.Single>"/> /// </param> /// <param name="x"> /// The x coordinate of the event occurence. This can be null <see cref="System.Nullable<System.Single>"/> /// </param> /// <param name="y"> /// The y coordinate of the event occurence. This can be null <see cref="System.Nullable<System.Single>"/> /// </param> private void CreateNewEvent(string eventName, float?eventValue) { Hashtable parameters = new Hashtable() { { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.EventID], eventName }, { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Level], GA.SettingsGA.CustomArea.Equals(string.Empty)?Application.loadedLevelName:GA.SettingsGA.CustomArea } }; if (eventValue.HasValue) { parameters.Add(GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Value], eventValue.ToString()); } GA_Queue.AddItem(parameters, GA_Submit.CategoryType.GA_Event, false); GA_AdSupport.ShowAdStatic(GA_AdSupport.GAEventType.Custom, GA_AdSupport.GAEventCat.Design, eventName); #if UNITY_EDITOR if (GA.SettingsGA.DebugAddEvent) { string options = ""; if (eventValue.HasValue) { options = ", value: " + eventValue; } GA.Log("GA Design Event added: " + eventName + options, true); } #endif }
void OnDestroy() { if (GA_ADSUPPORT == this) { GA_ADSUPPORT = null; } }
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 }
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); 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) { if (FindObjectOfType(typeof(Chartboost)) == null) { GameObject go = new GameObject("ChartboostManager"); go.AddComponent <Chartboost>(); Chartboost.didDismissInterstitial += OnDismissInterstitialEvent; Chartboost.didCloseInterstitial += OnCloseInterstitialEvent; Chartboost.didClickInterstitial += OnClickInterstitialEvent; Chartboost.didDisplayInterstitial += OnShowInterstitialEvent; } } #endif }
/// <summary> /// Used for player purchases /// </summary> /// <param name="businessID"> /// The business identifier. F.x. "Rocket Launcher Upgrade" <see cref="System.String"/> /// </param> /// <param name="currency"> /// Abbreviation of the currency used for the transaction. F.x. USD (U.S. Dollars) <see cref="System.String"/> /// </param> /// <param name="amount"> /// The value of the transaction in the lowest currency unit. F.x. if currency is USD then amount should be in cent <see cref="System.Int32"/> /// </param> private void CreateNewEvent(string eventName, string currency, int amount, float?x, float?y, float?z) { Hashtable parameters = new Hashtable() { { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.EventID], eventName }, { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Currency], currency }, { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Amount], amount.ToString() }, { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Level], GA.SettingsGA.CustomArea.Equals(string.Empty)?Application.loadedLevelName:GA.SettingsGA.CustomArea } }; if (x.HasValue) { parameters.Add(GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.X], (x * GA.SettingsGA.HeatmapGridSize.x).ToString()); } if (y.HasValue) { parameters.Add(GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Y], (y * GA.SettingsGA.HeatmapGridSize.y).ToString()); } if (z.HasValue) { parameters.Add(GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Z], (z * GA.SettingsGA.HeatmapGridSize.z).ToString()); } GA_Queue.AddItem(parameters, GA_Submit.CategoryType.GA_Purchase, false); GA_AdSupport.ShowAdStatic(GA_AdSupport.GAEventType.Custom, GA_AdSupport.GAEventCat.Business, eventName); #if UNITY_EDITOR if (GA.SettingsGA.DebugAddEvent) { string options = ""; if (x.HasValue && y.HasValue && z.HasValue) { options = ", x: " + x + ", y: " + y + ", z: " + z; } GA.Log("GA Business Event added: " + eventName + ", currency: " + currency + ", amount: " + amount + options, true); } #endif }
/// <summary> /// Used for player purchases /// </summary> /// <param name="businessID"> /// The business identifier. F.x. "Rocket Launcher Upgrade" <see cref="System.String"/> /// </param> /// <param name="currency"> /// Abbreviation of the currency used for the transaction. F.x. USD (U.S. Dollars) <see cref="System.String"/> /// </param> /// <param name="amount"> /// The value of the transaction in the lowest currency unit. F.x. if currency is USD then amount should be in cent <see cref="System.Int32"/> /// </param> private void CreateNewEvent(string eventName, string currency, int amount) { Hashtable parameters = new Hashtable() { { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.EventID], eventName }, { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Currency], currency }, { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Amount], amount.ToString() }, { GA_ServerFieldTypes.Fields[GA_ServerFieldTypes.FieldType.Level], GA.SettingsGA.CustomArea.Equals(string.Empty)?Application.loadedLevelName:GA.SettingsGA.CustomArea } }; GA_Queue.AddItem(parameters, GA_Submit.CategoryType.GA_Purchase, false); GA_AdSupport.ShowAdStatic(GA_AdSupport.GAEventType.Custom, GA_AdSupport.GAEventCat.Business, eventName); #if UNITY_EDITOR if (GA.SettingsGA.DebugAddEvent) { GA.Log("GA Business Event added: " + eventName + ", currency: " + currency + ", amount: " + amount, true); } #endif }
private void CheckAdNetwork(GA_Settings ga, GA_AdSupport.GAAdNetwork AdNetwork) { if (AdNetwork == GA_AdSupport.GAAdNetwork.iAd && !GA.SettingsGA.IAD_enabled || AdNetwork == GA_AdSupport.GAAdNetwork.Chartboost && !GA.SettingsGA.CB_enabled) { Rect lastrect = GUILayoutUtility.GetLastRect(); Color tmpColor = GUI.color; int tmpSize = GUI.skin.label.fontSize; GUI.color = Color.red; GUI.DrawTexture(new Rect(lastrect.x - 2, lastrect.y - 1, 5, 17), _triggerAdNotEnabledTexture); GUI.color = Color.white; GUI.skin.label.fontSize = 20; GUI.Label(new Rect(lastrect.x - 5, lastrect.y - 7, 20, 30), _triggerAdNotEnabled); GUI.skin.label.fontSize = tmpSize; GUI.color = tmpColor; } }
void OnDestroy() { if (GA_ADSUPPORT == this) GA_ADSUPPORT = null; }