using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

namespace MPStudio
{
    public class SetScreen : MonoBehaviour
    {
        public bool isOld = false;
        //横1竖0
        private void SetMatchWidthOrHeight()
        {
            
             float longNumber =isOld? 1334:1920;
             float shortNumber =isOld? 750:1080;

            bool isLandscape = longNumber > shortNumber;

            CanvasScaler canvasScaler = GetComponent<CanvasScaler>();
            canvasScaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;

            canvasScaler.screenMatchMode = CanvasScaler.ScreenMatchMode.Expand;

            canvasScaler.referenceResolution = new Vector2(longNumber, shortNumber);
            canvasScaler.referenceResolution = new Vector2(shortNumber, longNumber);
            if (isOld == true)
            {
                if (isLandscape)
                {
                   
                    canvasScaler.matchWidthOrHeight = 1;
                }
                else
                {
                    
                    canvasScaler.matchWidthOrHeight = 0;
                }
            }
        }

        private void Reset()
        {
            SetMatchWidthOrHeight();
        }

    }
}