示例#1
0
        public static ResolutionOption GetLargestSupportedResolution()
        {
            ResolutionOption maxResolution = new ResolutionOption();

            if (_resoltions == null)
            {
                _resoltions = Screen.resolutions;
            }

            for (int i = 0; i < _resoltions.Length; i++)
            {
                ResolutionOption resolution = new ResolutionOption(_resoltions[i]);
                if (resolution > maxResolution)
                {
                    maxResolution = resolution;
                }
            }

            if (maxResolution.IsSupported())
            {
                return(maxResolution);
            }

            return(new ResolutionOption(Screen.currentResolution));
        }
示例#2
0
        public int CompareTo(ResolutionOption other)
        {
            if (_width * _height > other._width * other._height)
            {
                return(1);
            }
            if (_width * _height == other._width * other._height)
            {
                if (_width > other._width)
                {
                    return(1);
                }

                return(_refreshRate.CompareTo(other._refreshRate));
            }
            return(-1);
        }
示例#3
0
        public static void CenterInScreen(this UnityEditor.EditorWindow window, float width, float height)
        {
            Vector2Int resolution = ResolutionOption.GetLargestSupportedResolution().Dimensions;

            window.position = new Rect((resolution.x - width) * 0.5f, (resolution.y - height) * 0.5f, width, height);
        }
示例#4
0
 public bool Equals(ResolutionOption other)
 {
     return(_width == other._width && _height == other._height && _refreshRate == other._refreshRate);
 }