コード例 #1
0
ファイル: GameConfig.cs プロジェクト: DeveloperFor/Hall
    static public ScreenRatio GetScreenRatio()
    {
        if (_Ratio != ScreenRatio.None)
        {
            return(_Ratio);
        }

        float ratio = (float)Screen.width / Screen.height;

        if (Mathf.Abs(ratio - (4 / 3f)) < 0.05f)
        {
            _Ratio = ScreenRatio._43;
        }
        else if (Mathf.Abs(ratio - (3 / 2f)) < 0.05f)
        {
            _Ratio = ScreenRatio._32;
        }
        else if (Mathf.Abs(ratio - (16 / 9f)) < 0.05f)
        {
            _Ratio = ScreenRatio._169;
        }
        else if (Mathf.Abs(ratio - (16 / 10f)) < 0.05f)
        {
            _Ratio = ScreenRatio._1610;
        }
        else
        {
            _Ratio = ScreenRatio._169;
        }

        return(_Ratio);
    }
コード例 #2
0
        public static ScreenRatio GetAspectRatioForResolution(int width, int height)
        {
            float ratio = (float)width / (float)height;

            Dictionary <float, ScreenRatio> ratios = new Dictionary <float, ScreenRatio>();

            ratios.Add(s3x4, ScreenRatio.r3x4);
            ratios.Add(s4x3, ScreenRatio.r4x3);
            ratios.Add(s2x3, ScreenRatio.r2x3);
            ratios.Add(s3x2, ScreenRatio.r3x2);
            ratios.Add(s5x3, ScreenRatio.r5x3);
            ratios.Add(s3x5, ScreenRatio.r3x5);
            ratios.Add(s9x16, ScreenRatio.r9x16);
            ratios.Add(s16x9, ScreenRatio.r16x9);
            ratios.Add(s16x10, ScreenRatio.r16x10);
            ratios.Add(s10x16, ScreenRatio.r10x16);

            ScreenRatio nearestRatio = ScreenRatio.r16x9;
            float       ratioDiff    = float.MaxValue;
            float       diff;

            foreach (KeyValuePair <float, ScreenRatio> r in ratios)
            {
                diff = Mathf.Abs(r.Key - ratio);
                if (diff < ratioDiff)
                {
                    ratioDiff    = diff;
                    nearestRatio = r.Value;
                }
            }

            return(nearestRatio);
        }
コード例 #3
0
ファイル: MonitorTest.cs プロジェクト: dytel/ORSAP_MONITOR
        public void SetStandHeightSixteenOnNine_PossitiveTest(double HeightStand,
                                                              ScreenRatio screenRatio)
        {
            var monitor = new MonitorSetting();

            monitor.ScreenRatio = screenRatio;
            monitor.StandHeight = HeightStand;
        }
コード例 #4
0
ファイル: MonitorTest.cs プロジェクト: dytel/ORSAP_MONITOR
        public void SetMonitorWighttSixteenOnNine_PossitiveTest(double WightMonitor,
                                                                ScreenRatio screenRatio)
        {
            var monitor = new MonitorSetting();

            monitor.ScreenRatio  = screenRatio;
            monitor.MonitorWight = WightMonitor;
        }
コード例 #5
0
ファイル: MonitorTest.cs プロジェクト: dytel/ORSAP_MONITOR
        public void SetRadiusSixteenOnNine_PossitiveTest(double Radius,
                                                         ScreenRatio screenRatio)
        {
            var monitor = new MonitorSetting();

            monitor.ScreenRatio = screenRatio;
            monitor.Radius      = Radius;
        }
コード例 #6
0
ファイル: MonitorTest.cs プロジェクト: dytel/ORSAP_MONITOR
        public void SetMonitorWightSixteenOnNine_NegativTest(double WightMonitor,
                                                             ScreenRatio screenRatio)
        {
            var monitor = new MonitorSetting();

            monitor.ScreenRatio = screenRatio;
            Assert.Throws <MonitorSettings.ExceptionFolder.WightMonitorException>(() =>
                                                                                  monitor.MonitorWight = WightMonitor);
        }
コード例 #7
0
ファイル: MonitorTest.cs プロジェクト: dytel/ORSAP_MONITOR
        public void SetRadiusSixteenOnNine_NegativTest(double Radius,
                                                       ScreenRatio screenRatio)
        {
            var monitor = new MonitorSetting();

            monitor.ScreenRatio = screenRatio;
            Assert.Throws <MonitorSettings.ExceptionFolder.RadiusException>(() =>
                                                                            monitor.Radius = Radius);
        }
コード例 #8
0
ファイル: MonitorTest.cs プロジェクト: dytel/ORSAP_MONITOR
        public void SetStandrWightSixteenOnNine_NegativTest(double WightStand
                                                            , ScreenRatio screenRatio)
        {
            var monitor = new MonitorSetting();

            monitor.ScreenRatio = ScreenRatio.SixteenOnNine;
            Assert.Throws <MonitorSettings.ExceptionFolder.WightStandeException>(() =>
                                                                                 monitor.StandeWight = WightStand);
        }
コード例 #9
0
ファイル: MonitorTest.cs プロジェクト: dytel/ORSAP_MONITOR
        public void SetStandHeightThreeByTwo_NegativTest(double HeightStand,
                                                         ScreenRatio screenRatio)
        {
            var monitor = new MonitorSetting();

            monitor.ScreenRatio = screenRatio;
            Assert.Throws <MonitorSettings.ExceptionFolder.HeightStandeException>(() =>
                                                                                  monitor.StandHeight = HeightStand);
        }
コード例 #10
0
    void Awake()
    {
        TouchArea.size   = new Vector2(TouchArea.size.x, TouchArea.size.y + ScreenRatio.SizeDiff());
        TouchArea.offset = new Vector2(TouchArea.offset.x, TouchArea.offset.y + ScreenRatio.SizeDiff() / 2);
        //new scale
        float scale = ScreenRatio.CameraSize / 4.8f;

        ShelfList.transform.localScale    = new Vector3(scale, scale, 0);
        ShelfList.transform.localPosition = new Vector3(ShelfList.transform.localPosition.x,
                                                        ShelfList.transform.localPosition.y + ScreenRatio.SizeDiff() / 2, 0);
        PrevPageArrow.OnReleased += PrevPage;
        NextPageArrow.OnReleased += NextPage;
    }
コード例 #11
0
        private void RefreshScreenSetting()
        {
            currentScreenSize  = new Vector2(Screen.width, Screen.height);
            ScreenHeightInInch = Screen.height / Screen.dpi;


            float aspectRatio = ((float)Screen.width) / ((float)Screen.height);


            ScreenRatio closestRatio = ScreenRatio.Ratio_9_20;
            float       closestDiff  = 100f;


            string[] allScreenRatio = System.Enum.GetNames(typeof(ScreenRatio));
            for (int i = 0; i < allScreenRatio.Length; i++)
            {
                string[] getRatio = allScreenRatio[i].Split('_');

                float ratioX = float.Parse(getRatio[1]);
                float ratioY = float.Parse(getRatio[2]);

                float currentDiff = aspectRatio - (ratioX / ratioY);


                if (currentDiff < -0.01f)
                {
                    continue;
                }

                if (currentDiff < closestDiff)
                {
                    closestDiff        = currentDiff;
                    closestRatio       = (ScreenRatio)Enum.Parse(typeof(ScreenRatio), allScreenRatio[i]);
                    ScreenRatioPercent = (ratioX / ratioY);
                }
            }


            ScreenRatio = closestRatio;

            Debug.Log("ScreenRatio = " + ScreenRatio);

            ScreenSizeChanged.Invoke();
        }
コード例 #12
0
 // Use this for initialization
 void Start()
 {
     //set boxcollider size due to Area size
     //640x960 = 6.3
     touchArea.size = new Vector2(touchArea.size.x, touchArea.size.y + ScreenRatio.SizeDiff() * 2);
 }
コード例 #13
0
 void Awake()
 {
     TouchCollider.size   = new Vector2(TouchCollider.size.x, TouchCollider.size.y + ScreenRatio.SizeDiff() * 2);
     TouchCollider.offset = new Vector2(TouchCollider.offset.x, TouchCollider.offset.y - ScreenRatio.SizeDiff());
 }
コード例 #14
0
 // Use this for initialization
 void Start()
 {
     touchArea.size = new Vector2(touchArea.size.x, touchArea.size.y + ScreenRatio.SizeDiff() * 2);
 }
コード例 #15
0
 // Use this for initialization
 void Awake()
 {
     ScreenRatio.SetupCamera();
 }