Beispiel #1
0
        /*
         * Event Handlers.
         */

        private static void OnSomethingChangedHandler(bool deviceOrientationChanged, bool screenResolutionChanged)
        {
            var interfaceTypeChanged = false;

            if (screenResolutionChanged)
            {
                var interfaceType = _agent.GetInterfaceType();
                if (interfaceType != CurrentInterfaceType)
                {
                    CurrentInterfaceType = interfaceType;
                    interfaceTypeChanged = true;
                }
            }

            if (deviceOrientationChanged)
            {
                OnDeviceOrientationChanged?.Invoke();
            }

            if (screenResolutionChanged)
            {
                OnScreenResolutionChanged?.Invoke();
            }

            if (interfaceTypeChanged)
            {
                OnInterfaceTypeChanged?.Invoke(CurrentInterfaceType);
            }

            if (deviceOrientationChanged || screenResolutionChanged)
            {
                OnSomethingChanged?.Invoke();
            }
        }
    // Update is called once per frame
    void Update()
    {
        // Update the resolution if necessary
        if (Screen.width != currentWidth || Screen.height != currentHeight)
        {
            currentWidth  = Screen.width;
            currentHeight = Screen.height;

            OnScreenResolutionChanged?.Invoke(currentWidth, currentHeight);
        }
    }
    private void Update()
    {
        var currentRes = new Vector2(Screen.width, Screen.height);

        if (currentRes != lastResolution)
        {
            LeftBottom = mainCamera.ScreenToWorldPoint(new Vector3(0, 0, mainCamera.nearClipPlane));
            RightUp    = mainCamera.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, mainCamera.nearClipPlane));
            OnScreenResolutionChanged?.Invoke();
            lastResolution = currentRes;
        }
    }