Ejemplo n.º 1
0
        // Update is called once per frame
        public void Update()
        {
            FPlatform.IncrementFrameCounter();

            if (FPlatform.IsWindowResized())
            {
                FUtil.SafeSendAnyEvent(OnWindowResized);
            }

            // update our wrappers around various different Input modes
            InputExtension.Get.Update();

            // update cockpit tracking and let UI do per-frame rendering computations
            if (options.EnableCockpit)
            {
                ActiveCockpit.Update();
            }

            // hardcoded Q key quits app
            if (Input.GetKeyUp(KeyCode.Q))
            {
                Cursor.lockState = CursorLockMode.None;
                GlobalControl.Quit();
            }

            // run per-frame actions
            Action execActions = nextFrameActions.GetRunnable();

            nextFrameActions.Clear();
            execActions();


            // can either use spacecontrols or mouse, but not both at same time
            // [TODO] ask spatial input controller instead, it knows better (?)
            if (FPlatform.IsUsingVR() && SpatialController.CheckForSpatialInputActive())
            {
                Configure_SpaceControllers();
                HandleInput_SpaceControllers();
            }
            else if (FPlatform.IsTouchDevice())
            {
                Configure_TouchInput();
                HandleInput_Touch();
            }
            else
            {
                Configure_MouseOrGamepad();
                HandleInput_MouseOrGamepad();
            }

            // after we have handled input, do per-frame rendering computations
            if (options.EnableCockpit)
            {
                ActiveCockpit.PreRender();
            }
            ToolManager.PreRender();
            Scene.PreRender();
        }