private void AddImpressionHandler(GameObject target) { ImpressionHandler handler = null; var transform = target.GetComponent <RectTransform> (); if (null != transform) { handler = target.AddComponent <ImpressionHandlerUI> (); } else { handler = target.AddComponent <ImpressionHandlerGO> (); } if (null != handler) { handler.OnImpression = () => { m_IsImpression = true; SendImpression(); DestroyImpressionHandlers(); }; m_Handlers.Add(handler); } else { Log.W("Couldn't be possible to detect an impression. {0}", target.name); } }
private void AddClickHandler(GameObject target, Action callback) { ClickHandler handler = null; var canvas = target.GetComponentInParent <Canvas> (); if (null != canvas) { handler = target.AddComponent <ClickHandlerUI> (); } else { var collider = target.GetComponent <Collider> (); if (null != collider) { handler = target.AddComponent <ClickHandler3D> (); } else { var collider2D = target.GetComponent <Collider2D> (); if (null != collider2D) { handler = target.AddComponent <ClickHandler2D> (); } } } if (null != handler) { handler.OnClick = callback; m_Handlers.Add(handler); } else { Log.W("Couldn't be to clickable. {0}", target.name); } }
/// <summary> /// Load fullboard ad. /// </summary> public void Load() { if (m_isLoading) { Log.W("An ad is already loading."); return; } LoadInternal(); m_isLoading = true; }
public void EnableAutoReload(double interval, Callback callback) { if (MinimumReloadInterval <= interval) { m_ReloadCallback = callback; m_Timer.Start(interval); } else { Log.W("A reload interval is less than 30 seconds."); } }
/// <summary> /// Show fullboard ad on the screen. /// </summary> public void Show() { if (m_isShowing) { Log.W("An ad is already showing."); return; } if (!m_isLoadSuccess) { Log.W("There is no ad to show."); return; } ShowInternal(); m_isShowing = true; }
protected override bool IsViewable() { var camera = Camera.main; var position = camera.WorldToScreenPoint(gameObject.transform.position); Log.D("WorldToScreenPoint: " + position); try { var bounds = GetBounds(); Rect rect = GetObjectRect(bounds); Log.D("The rect of {0}: " + rect, gameObject.name); var left = position.x - rect.width / 2; var right = position.x + rect.width / 2; var top = position.y + rect.height / 2; var bottom = position.y - rect.height / 2; return(CheckViewablePercentage(new Corner(left, top, right, bottom))); } catch (InvalidOperationException e) { Log.W(e.Message); Destroy(this); } return(false); }