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); }
public void AddScreenResolutionChangeCallback(OnScreenResolutionChange callback) { screenResolutionChangeCallbacks.Add(callback); }
public void CallOnScreenResolutionChange(EventData ob = null) => OnScreenResolutionChange?.Invoke(ob);