Пример #1
0
 private UniWebViewEdgeInsets InsetsForScreenOreitation(UniWebView webView, UniWebViewOrientation orientation)
 {
     if (orientation == UniWebViewOrientation.Portrait)
     {
         return(new UniWebViewEdgeInsets(5, 5, 5, 5));
     }
     return(new UniWebViewEdgeInsets(5, 5, 5, 5));
 }
 private UniWebViewEdgeInsets InsetsForScreenOreitation(UniWebView webView, UniWebViewOrientation orientation)
 {
     int aBottom = (int) (UniWebViewHelper.screenHeight * 0.5f);
     if (orientation == UniWebViewOrientation.Portrait)
     {
         return new UniWebViewEdgeInsets(5, 5, aBottom, 5);
     }
     return new UniWebViewEdgeInsets(5, 5, aBottom, 5);
 }
Пример #3
0
    // This method will be called when the screen orientation changed. Here we returned UniWebViewEdgeInsets(5,5,bottomInset,5)
    // for both situation. Although they seem to be the same, screenHeight was changed, leading a difference between the result.
    // eg. on iPhone 5, bottomInset is 284 (568 * 0.5) in portrait mode while it is 160 (320 * 0.5) in landscape.
    UniWebViewEdgeInsets InsetsForScreenOreitation(UniWebView webView, UniWebViewOrientation orientation)
    {
        int bottomInset = (int)(UniWebViewHelper.screenHeight * 0.17f);

        if (orientation == UniWebViewOrientation.Portrait) {
            return new UniWebViewEdgeInsets(5,5,bottomInset,5);
        } else {
            return new UniWebViewEdgeInsets(5,5,bottomInset,5);
        }
    }
Пример #4
0
    private UniWebViewEdgeInsets InsetsForScreenOreitation(UniWebView webView, UniWebViewOrientation orientation)
    {
        int aBottom = (int)((double)UniWebViewHelper.screenHeight * 0.5);

        if (orientation == UniWebViewOrientation.Portrait)
        {
            return(new UniWebViewEdgeInsets(5, 5, aBottom, 5));
        }
        return(new UniWebViewEdgeInsets(5, 5, aBottom, 5));
    }
Пример #5
0
 /// <summary>
 /// 显示参数变化处理
 /// </summary>
 /// <param name="webView"></param>
 /// <param name="orientation"></param>
 /// <returns></returns>
 private UniWebViewEdgeInsets OnInsersChange(UniWebView webView, UniWebViewOrientation orientation)
 {
     if (_curWebView)
     {
         _curWebView        = webView;
         _curWebView.Insets = GetShowParam();
         return(_curWebView.Insets);
     }
     return(UniWebViewEdgeInsets.Zero);
 }
Пример #6
0
 // This method will be called when the screen orientation changed. Here we return UniWebViewEdgeInsets(5,5,5,5)
 // for both situation, which means the inset is 5 point for iOS and 5 pixels for Android from all edges.
 // Note: UniWebView is using point instead of pixel in iOS. However, the `Screen.width` and `Screen.height` will give you a
 // pixel-based value.
 // You could get a point-based screen size by using the helper methods: `UniWebViewHelper.screenHeight` and `UniWebViewHelper.screenWidth` for iOS.
 UniWebViewEdgeInsets InsetsForScreenOreitation(UniWebView webView, UniWebViewOrientation orientation)
 {
     if (orientation == UniWebViewOrientation.Portrait)
     {
         return(new UniWebViewEdgeInsets(50, 50, 50, 50));
     }
     else
     {
         return(new UniWebViewEdgeInsets(50, 50, 50, 50));
     }
 }
Пример #7
0
 //< 처음 셋팅하는부분(UI)
 UniWebViewEdgeInsets InsetsForScreenOreitation(UniWebView webView, UniWebViewOrientation orientation)
 {
     if (orientation == UniWebViewOrientation.Portrait)
     {
         return(new UniWebViewEdgeInsets(CreatePos.top, CreatePos.left, CreatePos.bottom, CreatePos.right));
     }
     else
     {
         return(new UniWebViewEdgeInsets(CreatePos.top, CreatePos.left, CreatePos.bottom, CreatePos.right));
     }
 }
Пример #8
0
    UniWebViewEdgeInsets InsetsForScreenOreitation(UniWebView webView, UniWebViewOrientation orientation)
    {
        Debug.Log("InsetsForScreenOreitation");

        float myRatio = Screen.width / 720f;

        //		if(Screen.height > Constants.SCREEN_HEIGHT_ORIGINAL){
        return(new UniWebViewEdgeInsets((int)(Constants.WEBVIEW_GAB_TOP * myRatio), 0, 0, 0));
        //		} else {
        //			return new UniWebViewEdgeInsets((int)(125*myRatio)+Constants.HEIGHT_STATUS_BAR,0,0,0);
        //		}
    }
Пример #9
0
    // This method will be called when the screen orientation changed. Here we returned UniWebViewEdgeInsets(5,5,bottomInset,5)
    // for both situation. Although they seem to be the same, screenHeight was changed, leading a difference between the result.
    // eg. on iPhone 5, bottomInset is 284 (568 * 0.5) in portrait mode while it is 160 (320 * 0.5) in landscape.
    UniWebViewEdgeInsets InsetsForScreenOreitation(UniWebView webView, UniWebViewOrientation orientation)
    {
        int bottomInset = (int)(UniWebViewHelper.screenHeight * 0.5f);

        if (orientation == UniWebViewOrientation.Portrait)
        {
            return(new UniWebViewEdgeInsets(5, 5, bottomInset, 5));
        }
        else
        {
            return(new UniWebViewEdgeInsets(5, 5, bottomInset, 5));
        }
    }
Пример #10
0
    private void ResizeInternal()
    {
        int screenHeight            = UniWebViewHelper.screenHeight;
        int screenWidth             = UniWebViewHelper.screenWidth;
        UniWebViewEdgeInsets insets = this.insets;

        if (this.InsetsForScreenOreitation != null)
        {
            UniWebViewOrientation orientation = (screenHeight < screenWidth) ? UniWebViewOrientation.LandScape : UniWebViewOrientation.Portrait;
            insets = this.InsetsForScreenOreitation(this, orientation);
        }
        this.ForceUpdateInsetsInternal(insets);
    }
Пример #11
0
        private UniWebViewEdgeInsets InsetsForScreenOreitation(UniWebView webView, UniWebViewOrientation orientation)
        {
            Vector3[] vector3Array = new Vector3[4];
            this.WebViewContainer.GetWorldCorners(vector3Array);
            float num1    = (float)ScreenUtility.DefaultScreenWidth / (float)Screen.get_width();
            float num2    = (float)ScreenUtility.DefaultScreenHeight / (float)Screen.get_height();
            int   aLeft   = (int)(vector3Array[0].x * (double)num1);
            int   aRight  = (int)(((double)Screen.get_width() - vector3Array[2].x) * (double)num1);
            int   aTop    = (int)(((double)Screen.get_height() - vector3Array[1].y) * (double)num2);
            int   aBottom = (int)(vector3Array[0].y * (double)num2);

            return(new UniWebViewEdgeInsets(aTop, aLeft, aBottom, aRight));
        }
Пример #12
0
	private void ResizeInternal() {
		int newHeight = UniWebViewHelper.screenHeight;
		int newWidth = UniWebViewHelper.screenWidth;

		UniWebViewEdgeInsets newInset = this.insets;
		if (InsetsForScreenOreitation != null) {
			UniWebViewOrientation orientation =
				newHeight >= newWidth ? UniWebViewOrientation.Portrait : UniWebViewOrientation.LandScape;
            newInset = InsetsForScreenOreitation(this, orientation);
        }

        ForceUpdateInsetsInternal(newInset);
    }
Пример #13
0
    UniWebViewEdgeInsets InsetsForScreenOreitation(UniWebView webView, UniWebViewOrientation orientation)
    {
        float webViewTop    = 0;                        // マージン:上
        float widthMarzine  = 0;                        // マージン:横
        float webViewBottom = m_ButtomRect.sizeDelta.y; // マージン:下

        if (m_WebViewFixID != 0)
        {
            webViewBottom = m_PopupButtomRect.sizeDelta.y; // マージン:下
        }

        float screenWidth  = UniWebViewHelper.screenWidth;  // 画面サイズ:横幅
        float screenHeight = UniWebViewHelper.screenHeight; // 画面サイズ:高さ

        Canvas canvas       = GetComponentInChildren <Canvas>();
        float  canvasHeight = 0; // Canvasサイズ:高さ
        float  canvasWidth  = 0; // Canvasサイズ:横幅

        if (canvas != null)
        {
            RectTransform rect = canvas.GetComponent <RectTransform>();
            canvasHeight = rect.rect.height;
            canvasWidth  = rect.rect.width;
        }

        // Canvasの基準解像度:横の縦からの割合
        float baseWidthRatio = GlobalDefine.SCREEN_SIZE_W / canvasHeight;

        // 起動デバイスの解像度:横の縦からの割合
        float revWidthRatio = screenWidth / screenHeight;

        if (baseWidthRatio < revWidthRatio)
        {
            // 両サイドのマージン領域を求める。
            widthMarzine = (canvasWidth - GlobalDefine.SCREEN_SIZE_W) / 2.0f;
        }

        // 基準サイズとスクリーンサイズの横幅の比率を求める
        float rate = screenHeight / canvasHeight;

        webViewBottom *= rate;
        widthMarzine  *= rate;

        // トップのマージンはAndroid実機の場合Activityからとってくる(ステータスバー対策)
#if !UNITY_EDITOR
        webViewTop = SafeAreaControl.Instance.getNativeTop();
#endif

        return(new UniWebViewEdgeInsets((int)webViewTop, (int)widthMarzine, (int)webViewBottom, (int)widthMarzine));
    }
Пример #14
0
        UniWebViewEdgeInsets InsetsForScreenOreitation(UniWebView webView, UniWebViewOrientation orientation)
        {
#if UNITY_IOS
            //var topInset = 0;
            //var bottomInset = 0;

            //var iphoneGen=UnityEngine.iOS.Device.generation;
            //if(iphoneGen==UnityEngine.iOS.DeviceGeneration.iPhone5S)
            //{
            //    topInset=54;
            //    bottomInset=34;
            //}
            //else if(iphoneGen==UnityEngine.iOS.DeviceGeneration.iPhone6)
            //{
            //    topInset=64;
            //    bottomInset=40;
            //}
            //else if(iphoneGen==UnityEngine.iOS.DeviceGeneration.iPhone6Plus)
            //{
            //    topInset=70;
            //    bottomInset=44;
            //}

            //if (orientation == UniWebViewOrientation.Portrait)
            //{
            //    return new UniWebViewEdgeInsets(topInset, 0, bottomInset, 0);
            //}
            //else
            //{
            //    return new UniWebViewEdgeInsets(topInset, 0, bottomInset, 0);
            //}
#elif UNITY_ANDROID
            //if (orientation == UniWebViewOrientation.Portrait)
            //{
            //    return new UniWebViewEdgeInsets(0, 0, 0, 120);
            //}
            //else
            //{
            //    return new UniWebViewEdgeInsets(0, 0, 0, 120);
            //}
#endif
            if (orientation == UniWebViewOrientation.Portrait)
            {
                return(new UniWebViewEdgeInsets(0, 0, 0, 0));
            }
            else
            {
                return(new UniWebViewEdgeInsets(0, 0, 0, 0));
            }
        }
Пример #15
0
 // This method will be called when the screen orientation changed. Here we return UniWebViewEdgeInsets(0,0,0,0)
 // for both situation, which means the inset is 0 point for iOS and 0 pixels for Android from all edges.
 // Note: UniWebView is using point instead of pixel in iOS. However, the `Screen.width` and `Screen.height` will give you a
 // pixel-based value.
 // You could get a point-based screen size by using the helper methods: `UniWebViewHelper.screenHeight` and `UniWebViewHelper.screenWidth` for iOS.
 UniWebViewEdgeInsets InsetsForScreenOreitation(UniWebView webView, UniWebViewOrientation orientation)
 {
     if (orientation == UniWebViewOrientation.Portrait)
     {
         return(new UniWebViewEdgeInsets(0, 0, Convert.ToInt32(RightPanel.GetComponent <RectTransform>().sizeDelta.x - 30), 0));
     }
     else
     {
         if (Screen.orientation == ScreenOrientation.LandscapeLeft)
         {
             return(new UniWebViewEdgeInsets(0, 0, 0, Convert.ToInt32(RightPanel.GetComponent <RectTransform>().sizeDelta.x - 30)));
         }
         if (Screen.orientation == ScreenOrientation.LandscapeRight)
         {
             return(new UniWebViewEdgeInsets(0, 0, 0, Convert.ToInt32(RightPanel.GetComponent <RectTransform>().sizeDelta.x - 30)));
         }
     }
     return(new UniWebViewEdgeInsets(0, 0, 0, 0));
 }
Пример #16
0
    private UniWebViewEdgeInsets InsetsForScreenOreitation(UniWebView webView, UniWebViewOrientation orientation)
    {
        GameObject gObj  = GameObject.Find("Top");
        UI2DSprite uI2DS = gObj.GetComponent <UI2DSprite> ();

        int width = Screen.width;
        int aTop  = (int)(Screen.height / 10);

        UIRoot mRoot = NGUITools.FindInParents <UIRoot> (gObj);
        float  ratio = (float)mRoot.activeHeight / Screen.height;

        int NGUIwidth  = (int)(Mathf.Ceil(width * ratio));
        int NGUIheight = (int)(Mathf.Ceil(aTop * ratio));

        int x = NGUIwidth / 2;
        int y = mRoot.activeHeight / 2 - NGUIheight;

        uI2DS.SetRect(-x, y, NGUIwidth, NGUIheight);

        gObj  = GameObject.Find("Bottom");
        uI2DS = gObj.GetComponent <UI2DSprite> ();

        int aBottom = (int)(Screen.height / 11);

        NGUIheight = (int)(Mathf.Ceil(aBottom * ratio));
        y          = mRoot.activeHeight / 2 - NGUIheight;

        uI2DS.SetRect(-x, -y - NGUIheight, NGUIwidth, NGUIheight);

#if UNITY_EDITOR
        return(new UniWebViewEdgeInsets(aTop, 0, aBottom, 0));
#elif UNITY_IPHONE
        return(new UniWebViewEdgeInsets(aTop / 2, 0, aBottom / 2, 0));
#else
        return(new UniWebViewEdgeInsets(aTop, 0, aBottom, 0));
#endif
    }
Пример #17
0
    UniWebViewEdgeInsets InsetsForScreenOreitation(UniWebView webView, UniWebViewOrientation orientation)
    {
        Vector3[] fourCornersArray = new Vector3[4];
        mContent.GetWorldCorners(fourCornersArray);
        Camera cameraTmp = null;

        if (mCanvas.renderMode == RenderMode.ScreenSpaceOverlay)
        {
        }
        else
        {
            cameraTmp = mCanvas.worldCamera;
        }
        Vector2 bottomLeft = RectTransformUtility.WorldToScreenPoint(cameraTmp, fourCornersArray[0]);
        //Vector2 pos1 = cameraTmp.WorldToScreenPoint(fourCornersArray[1]);
        Vector2 topRight = RectTransformUtility.WorldToScreenPoint(cameraTmp, fourCornersArray[2]);
        //  Vector2 pos3 = cameraTmp.WorldToScreenPoint(fourCornersArray[3]);

        float _top    = Screen.height - topRight.y;
        float _left   = bottomLeft.x;
        float _bottom = bottomLeft.y;
        float _right  = Screen.width - topRight.x;

        if (orientation == UniWebViewOrientation.Portrait)  //竖屏
        {
            int offset = 0;

            return(new UniWebViewEdgeInsets(UniWebViewHelper.ConvertPixelToPoint(_top, false) + offset, UniWebViewHelper.ConvertPixelToPoint(_left, true) + offset, UniWebViewHelper.ConvertPixelToPoint(_bottom, false) + offset, UniWebViewHelper.ConvertPixelToPoint(_right, true) + offset));
        }
        else//横屏
        {
            int offset = 0;

            return(new UniWebViewEdgeInsets(UniWebViewHelper.ConvertPixelToPoint(_top, false) + offset, UniWebViewHelper.ConvertPixelToPoint(_left, true) + offset, UniWebViewHelper.ConvertPixelToPoint(_bottom, false) + offset, UniWebViewHelper.ConvertPixelToPoint(_right, true) + offset));
        }
    }
Пример #18
0
    private UniWebViewEdgeInsets InsetsForScreenOreitation(UniWebView webView, UniWebViewOrientation orientation)
    {
        int size = ((int)topBG.localSize.y + (int)(topBG.localSize.y / 2));

        return(new UniWebViewEdgeInsets(size, 0, 0, 0));
    }
Пример #19
0
 // This method will be called when the screen orientation changed. Here we returned UniWebViewEdgeInsets(5,5,bottomInset,5)
 // for both situation. Although they seem to be the same, screenHeight was changed, leading a difference between the result.
 // eg. on iPhone 5, bottomInset is 284 (568 * 0.5) in portrait mode while it is 160 (320 * 0.5) in landscape.
 UniWebViewEdgeInsets InsetsForScreenOreitation(UniWebView webView, UniWebViewOrientation orientation)
 {
     return(new UniWebViewEdgeInsets(0, 0, 0, 0));
 }