Exemplo n.º 1
0
 public virtual void Dispose()
 {
     Log.D("Dispose NativeAdClient.");
     m_Callbacks.Clear();
     m_Timer.Dispose();
     m_Timer = null;
 }
        protected override bool IsViewable()
        {
            var rectTransform = gameObject.transform as RectTransform;

            if (((.0f >= rectTransform.sizeDelta.x || .0f >= rectTransform.sizeDelta.y) &&
                 (.0f >= rectTransform.rect.width || .0f >= rectTransform.rect.height)) ||
                .0f >= rectTransform.localScale.x || .0f >= rectTransform.localScale.y)
            {
                Log.D("{0}'s size or scale are less than or equal to zero.", gameObject.name);
                return(false);
            }

            var group = rectTransform.GetComponent <CanvasGroup> ();

            if (null != group && .0f >= group.alpha)
            {
                Log.D("{0}'s alpha is equal to zero.", gameObject.name);
                return(false);
            }

            rectTransform.GetWorldCorners(m_Corners);
            Log.D("WorldCorners: {0}, {1}, {2}, {3}, camera: {4}", m_Corners [0], m_Corners [1], m_Corners [2], m_Corners [3], m_Camera);
            Camera camera = (null != m_Canvas && RenderMode.ScreenSpaceOverlay == m_Canvas.renderMode) ? null : m_Camera;

            Vector2[] screenCorners = m_Corners.Select(v => RectTransformUtility.WorldToScreenPoint(camera, v)).ToArray();
            Log.D("ScreenCorners: {0}, {1}, {2}, {3}, camera: {4}", screenCorners [0], screenCorners [1], screenCorners [2], screenCorners [3], m_Camera);

            float left   = Mathf.Min(screenCorners [0].x, screenCorners [1].x);
            float right  = Mathf.Max(screenCorners [2].x, screenCorners [3].x);
            float top    = Mathf.Max(screenCorners [1].y, screenCorners [2].y);
            float bottom = Mathf.Min(screenCorners [0].y, screenCorners [3].y);

            return(CheckViewablePercentage(new Corner(left, top, right, bottom)));
        }
Exemplo n.º 3
0
 public override void Dispose()
 {
     base.Dispose();
     Log.D("Dispose AndroidNativeAd.");
     if (null != m_NativeAd)
     {
         m_NativeAd.Dispose();
         m_NativeAd = null;
     }
 }
Exemplo n.º 4
0
 public override void Dispose()
 {
     base.Dispose();
     Log.D("Dispose AndroidNativeAdClient.");
     if (null != m_Client)
     {
         m_Client.Dispose();
         m_Client = null;
     }
 }
Exemplo n.º 5
0
 internal Texture2D Get(string url)
 {
     if (m_Cache.ContainsKey(url))
     {
         Log.D("Get texture from cache.");
         return(m_Cache [url]);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 6
0
 public override void Dispose()
 {
     base.Dispose();
     Log.D("Dispose IOSNativeAd.");
     _ReleaseNativeAd(m_NativeAdPtr);
     if (IntPtr.Zero != m_NativeAdPtr)
     {
         GCHandle handle = (GCHandle)m_NativeAdPtr;
         handle.Free();
         m_NativeAdPtr = IntPtr.Zero;
     }
 }
 internal static void Prepare()
 {
     if (null == s_Instance)
     {
         var go = new GameObject("NendAdMainThreadWorker");
         go.AddComponent <NendAdMainThreadWorker> ();
     }
     else
     {
         Log.D("NendAdMainThreadWorker is already prepared.");
     }
 }
Exemplo n.º 8
0
        private void CheckImpression()
        {
            Log.I("Checking whether the {0} is viewable.", gameObject.name);
            Vector3 cameraRelative = Camera.main.transform.InverseTransformPoint(gameObject.transform.position);

            if (0 < cameraRelative.z)
            {
                Log.D("The {0} is in front of the camera.", gameObject.name);
            }
            else
            {
                Log.D("The {0} is behind the camera.", gameObject.name);
                return;
            }
            if (IsViewable())
            {
                Log.I("The {0} is viewable!", gameObject.name);
                OnImpression();
            }
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
 void OnDestroy()
 {
     Log.D("OnDestroy: {0}", name);
     m_LoadedNativeAd  = null;
     m_ShowingNativeAd = null;
 }
Exemplo n.º 11
0
 public virtual void Dispose()
 {
     Log.D("Dispose NativeAd.");
     DestroyAllHandlers();
 }
Exemplo n.º 12
0
 void OnDestroy()
 {
     Log.D("ClickHandler#OnDestroy: {0}", gameObject.name);
 }
Exemplo n.º 13
0
        protected bool CheckViewablePercentage(Corner adCorner)
        {
            Rect screenSize = Camera.main.pixelRect;

            Log.D("screenSize: {0}, left: {1}, top: {2}, right: {3}, bottom: {4}",
                  screenSize, adCorner.left, adCorner.top, adCorner.right, adCorner.bottom);

            if (.0f > adCorner.right || screenSize.height < adCorner.bottom || screenSize.width < adCorner.left || .0f > adCorner.top)
            {
                Log.D("{0} is out of the screen.", gameObject.name);
                return(false);
            }

            var intersectWidth  = 0.0f;
            var intersectHeight = 0.0f;

            if (.0f > adCorner.left && screenSize.width < adCorner.right)
            {
                Log.D("{0}'s width is larger than width of camera.", gameObject.name);
                intersectWidth = screenSize.width;
            }
            else if (.0f > adCorner.left)
            {
                Log.D("Left side of {0} is sticking out.", gameObject.name);
                intersectWidth = adCorner.right;
            }
            else if (screenSize.width < adCorner.right)
            {
                Log.D("Right side of {0} is sticking out.", gameObject.name);
                intersectWidth = screenSize.width - adCorner.left;
            }
            else
            {
                intersectWidth = adCorner.right - adCorner.left;
            }

            if (.0f > adCorner.bottom && screenSize.height < adCorner.top)
            {
                Log.D("{0}'s height is larger than height of camera.", gameObject.name);
                intersectHeight = screenSize.height;
            }
            else if (.0f > adCorner.bottom)
            {
                Log.D("Bottom of {0} is sticking out.", gameObject.name);
                intersectHeight = adCorner.top;
            }
            else if (screenSize.height < adCorner.top)
            {
                Log.D("Top of {0} is sticking out.", gameObject.name);
                intersectHeight = screenSize.height - adCorner.bottom;
            }
            else
            {
                intersectHeight = adCorner.top - adCorner.bottom;
            }

            var   adWidth   = adCorner.right - adCorner.left;
            var   adHeight  = adCorner.top - adCorner.bottom;
            float intersect = intersectWidth * intersectHeight;
            float adSize    = adWidth * adHeight;

            Log.D("IntersectArea: {0}, AdArea: {1}", intersect, adSize);

            return(intersect >= adSize * VIEWABLE_PERCENTAGE);
        }
Exemplo n.º 14
0
 void OnDestroy()
 {
     Log.D("ImpressionHandler#OnDestroy: {0}", gameObject.name);
 }