Пример #1
0
        private void UpdateScreenResolution()
        {
            if (Screen.currentResolution.Equals(_resolution))
            {
                return;
            }

            _resolution = Screen.currentResolution;

            if (maintainWidth)
            {
                Cam.orthographicSize = _defaultOrthographicSizeTimesAspect / GetCameraAspect();

                var position = Transform.position;
                var y        = (_defaultOrthographicSize - Cam.orthographicSize) * adaptPosition;
                Transform.position = new Vector3(
                    position.x,
                    y,
                    position.z);
            }
            else
            {
                var position = Transform.position;
                var x        = (_defaultOrthographicSizeTimesAspect -
                                Cam.orthographicSize * GetCameraAspect()) * adaptPosition;
                Transform.position = new Vector3(
                    x,
                    position.y,
                    position.z);
            }

            OnScreenResolutionChange?.Invoke(_resolution);
            OnTranslate?.Invoke(Transform);
        }
Пример #2
0
 public void AddScreenResolutionChangeCallback(OnScreenResolutionChange callback)
 {
     screenResolutionChangeCallbacks.Add(callback);
 }
Пример #3
0
 public void CallOnScreenResolutionChange(EventData ob = null) => OnScreenResolutionChange?.Invoke(ob);