Esempio n. 1
0
        /// <summary>
        /// 広告の表示領域を返します
        /// </summary>
        /// <returns>広告の表示領域</returns>
        /// <param name="alignPosition">AdAlignPosition</param>
        /// <param name="valignPosition">AdValignPosition</param>
        /// <param name="adType">AdType</param>
        /// <param name="iconParams">IMobileIconParams</param>
        internal static Rect getAdRect(IMobileSdkAdsUnityPlugin.AdAlignPosition alignPosition, IMobileSdkAdsUnityPlugin.AdValignPosition valignPosition, IMobileSdkAdsUnityPlugin.AdType adType, IMobileIconParams iconParams)
        {
            iconParams = iconParams ?? new IMobileIconParams();

            // スクリーンの論理サイズを取得
            int screenWidth  = 0;
            int screenHeight = 0;

                        #if UNITY_IPHONE && !UNITY_EDITOR
            screenWidth  = getScreenWidth_(isScreenPortrait());
            screenHeight = getScreenHeight_(isScreenPortrait());
                        #elif UNITY_ANDROID
            screenWidth  = getDensitySize(Screen.width);
            screenHeight = getDensitySize(Screen.height);
                        #endif

            // 広告の表示位置を計算
            int x = 0;
            int y = 0;

            // 広告サイズを取得
            CGSize adSize = getAdSize(adType, iconParams);

            // x座標の取得
            switch (alignPosition)
            {
            case IMobileSdkAdsUnityPlugin.AdAlignPosition.LEFT:
                x = 0;
                break;

            case IMobileSdkAdsUnityPlugin.AdAlignPosition.CENTER:
                x = (screenWidth - adSize.width) / 2;
                break;

            case IMobileSdkAdsUnityPlugin.AdAlignPosition.RIGHT:
                x = screenWidth - adSize.width;
                break;
            }

            // y座標の取得
            switch (valignPosition)
            {
            case IMobileSdkAdsUnityPlugin.AdValignPosition.TOP:
                y = 0;
                break;

            case IMobileSdkAdsUnityPlugin.AdValignPosition.MIDDLE:
                y = (screenHeight / 2) - (adSize.height / 2);
                break;

            case IMobileSdkAdsUnityPlugin.AdValignPosition.BOTTOM:
                y = screenHeight - adSize.height;
                break;
            }

            return(getAdRect(x, y, adType, iconParams));
        }
        /// <summary>
        /// 広告の表示領域を返します
        /// </summary>
        /// <returns>広告の表示領域</returns>
        /// <param name="alignPosition">AdAlignPosition</param>
        /// <param name="valignPosition">AdValignPosition</param>
        /// <param name="adType">AdType</param>
        /// <param name="iconParams">IMobileIconParams</param>
        /// <param name="sizeAdjust">sizeAdjust</param>
        internal static Rect getAdRect(IMobileSdkAdsUnityPlugin.AdAlignPosition alignPosition, IMobileSdkAdsUnityPlugin.AdValignPosition valignPosition, IMobileSdkAdsUnityPlugin.AdType adType, IMobileIconParams iconParams, bool sizeAdjust)
        {
            // スクリーンの論理サイズを取得
            int screenWidth  = 0;
            int screenHeight = 0;

                        #if UNITY_IPHONE && !UNITY_EDITOR
            screenWidth  = getScreenWidth_(isScreenPortrait());
            screenHeight = getScreenHeight_(isScreenPortrait());
                        #elif UNITY_ANDROID && !UNITY_EDITOR
            screenWidth  = getDensitySize(Screen.width);
            screenHeight = getDensitySize(Screen.height);
                        #endif

            // 広告の表示位置を計算
            int left = 0;
            int top  = 0;

            // 広告サイズを取得
            iconParams = iconParams ?? new IMobileIconParams();
            CGSize adSize = getAdSize(adType, iconParams, sizeAdjust);

            // x座標の取得
            switch (alignPosition)
            {
            case IMobileSdkAdsUnityPlugin.AdAlignPosition.LEFT:
                left = 0;
                break;

            case IMobileSdkAdsUnityPlugin.AdAlignPosition.CENTER:
                left = (screenWidth - adSize.width) / 2;
                break;

            case IMobileSdkAdsUnityPlugin.AdAlignPosition.RIGHT:
                left = screenWidth - adSize.width;
                break;
            }

            // y座標の取得
            switch (valignPosition)
            {
            case IMobileSdkAdsUnityPlugin.AdValignPosition.TOP:
                top = 0;
                break;

            case IMobileSdkAdsUnityPlugin.AdValignPosition.MIDDLE:
                top = (screenHeight / 2) - (adSize.height / 2);
                break;

            case IMobileSdkAdsUnityPlugin.AdValignPosition.BOTTOM:
                #if UNITY_IOS
                top = screenHeight - adSize.height - 56;

                if (SystemInfo.deviceModel.Contains("iPad"))
                {
                    // ipadでの処理
                    top = screenHeight - adSize.height - 82; // ゴリ押しの修正
                }
                #else
                top = screenHeight - adSize.height - 48;
                #endif

                break;
            }

            return(new Rect(left, top, adSize.width, adSize.height));
        }