Example #1
0
    public void SetAspectRatio()
    {
        float ar = (float)Math.Round(((float)Screen.width / (float)Screen.height), 3);

        if (isLandscape)
        {
            ar = (float)Math.Round(((float)Screen.height / (float)Screen.width), 3);
        }
        //Debug.Log("aspect ratio :" + ar);

        if (ar == 0.667f)
        {
            aspectRatio = ScreenAspectRatio.TwoByThree;
        }
        else if (ar == 0.75f)
        {
            aspectRatio = ScreenAspectRatio.ThreeByFour;
        }
        else if (ar == 0.6f)
        {
            aspectRatio = ScreenAspectRatio.ThreeByFive;
        }
        else if (ar == 0.625f)
        {
            aspectRatio = ScreenAspectRatio.FiveByEight;
        }
        else if (ar == 0.562f)
        {
            aspectRatio = ScreenAspectRatio.NineBySixteen;
        }
        else if (ar == 0.462f)
        {
            aspectRatio = ScreenAspectRatio.iPhoneX;
        }
        else if (ar == 0.486f)
        {
            aspectRatio = ScreenAspectRatio.Samsung;
        }
        else if (ar == 0.586f)
        {
            aspectRatio = ScreenAspectRatio.KindleFire7;
        }
        else if (ar == 0.5f)
        {
            aspectRatio = ScreenAspectRatio.Pixel_OneByTwo;
        }
        else
        {
            aspectRatio = ScreenAspectRatio.NotFound;
        }

        rectTrans = this.GetComponent <RectTransform>();
    }
Example #2
0
 public UIChangeParam(int ratio)
 {
     aspectRatio = (ScreenAspectRatio)ratio;
     newScale    = Vector3.one;
 }