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)); }
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); }
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); }
public bool Equals(ResolutionOption other) { return(_width == other._width && _height == other._height && _refreshRate == other._refreshRate); }