Example #1
0
    private IEnumerator CheckForChange()
    {
        _resolution  = new Vector2Int(Screen.width, Screen.height);
        _orientation = Input.deviceOrientation;

        while (_isAlive)
        {
            // Check for a Resolution Change
            if (_resolution.x != Screen.width || _resolution.y != Screen.height)
            {
                _resolution = new Vector2Int(Screen.width, Screen.height);
                OnResolutionChange?.Invoke(_resolution);
            }

            // Check for an Orientation Change
            switch (Input.deviceOrientation)
            {
            case DeviceOrientation.Unknown:    // Ignore
            case DeviceOrientation.FaceUp:     // Ignore
            case DeviceOrientation.FaceDown:   // Ignore
                break;

            default:
                if (_orientation != Input.deviceOrientation)
                {
                    _orientation = Input.deviceOrientation;
                    OnOrientationChange?.Invoke(_orientation);
                }

                break;
            }

            yield return(new WaitForSeconds(CheckDelay));
        }
    }
Example #2
0
    protected void OnRectTransformDimensionsChange()
    {
        ScreenOrientation orientation = Screen.width > Screen.height ? ScreenOrientation.LandscapeLeft : ScreenOrientation.Portrait;

        switch (Screen.orientation)
        {
        case ScreenOrientation.LandscapeLeft:
        case ScreenOrientation.LandscapeRight:
            OnOrientationChange?.Invoke(ScreenOrientation.LandscapeLeft);
            break;

        case ScreenOrientation.Portrait:
        case ScreenOrientation.PortraitUpsideDown:
            OnOrientationChange?.Invoke(ScreenOrientation.Portrait);
            break;
        }
    }
Example #3
0
 private static void onOrientationChange(int angle)
 {
     OnOrientationChange.Invoke(angle);
 }