Esempio n. 1
0
    private void Refresh()
    {
        if (_cs == null)
        {
            return;
        }

        if (!IsResizeSourceChanged() && !IsScreenOrientationChanged() && !IsResolutionChanged())
        {
            return;
        }

        _lastRS         = _rs;
        _lastScreenOri  = Screen.orientation;
        _lastResolution = new Vector2(Screen.width, Screen.height);

        if (_rs == ResizeSource.ScreenSize)
        {
            _cs.referenceResolution = new Vector2(Screen.width, Screen.height);
            _cs.screenMatchMode     = CanvasScaler.ScreenMatchMode.MatchWidthOrHeight;
            _cs.matchWidthOrHeight  = Screen.width > Screen.height ? 0 : 1;
        }
        else if (_rs == ResizeSource.Customize)
        {
            Vector2 resolution = ResolutionUtility.GetCustomizedReferenceResolution();
            float   match      = ResolutionUtility.GetMatchWidthOrHeight();

            _cs.referenceResolution = new Vector2(resolution.x, resolution.y);
            _cs.screenMatchMode     = CanvasScaler.ScreenMatchMode.MatchWidthOrHeight;
            _cs.matchWidthOrHeight  = match;
        }

        if (onChanged != null)
        {
            onChanged();
        }
    }