void Update() { if (Input.anyKeyDown) //Some custom scenes to do funny stuff with { if (Input.GetKeyDown(KeyCode.F1)) { if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.LeftShift)) { Plugin.Log.Info("Reloading Camera2 Config..."); MovementScriptManager.LoadMovementScripts(true); CamManager.Reload(); } else { ScenesManager.LoadGameScene(); } } else { #if DEV if (Input.GetKeyDown(KeyCode.F7)) { Plugin.LoadShaders(); return; } #endif foreach (var k in ScenesManager.settings.customSceneBindings) { if (!Input.GetKeyDown(k.Key)) { continue; } ScenesManager.SwitchToCustomScene(k.Value); break; } } } // This doesnt really belong here..... var curRes = new Vector2(Screen.width, Screen.height); if (lastScreenRes != Vector2.zero) { foreach (var c in CamManager.cams) { c.Value.UpdateRenderTextureAndView(); } } lastScreenRes = curRes; if (HookFPFCToggle.isInFPFC) { if ((int)currentAction >= 2) { ProcessCamAction(true); } targetCam = null; return; } if (currentAction == CamAction.None && lastMousePos != Input.mousePosition) { if (!Application.isFocused) { return; } possibleAction = CamAction.None; lastMousePos = Input.mousePosition; if (lastMousePos.x < 0 || lastMousePos.y < 0 || lastMousePos.x > Screen.width || lastMousePos.y > Screen.height) { return; } var pCam = targetCam; targetCam = GetViewAtPoint(lastMousePos, ref possibleAction); if (targetCam != pCam) { if (targetCam != null) { targetCam.cam.PrepareMiddlewaredRender(true); } if (pCam != null) { pCam.cam.PrepareMiddlewaredRender(true); } } if (possibleAction == CamAction.Resize_BR || possibleAction == CamAction.Resize_TL) { WinAPI.SetCursor(WinAPI.WindowsCursor.IDC_SIZENWSE); } else if (possibleAction == CamAction.Resize_BL || possibleAction == CamAction.Resize_TR) { WinAPI.SetCursor(WinAPI.WindowsCursor.IDC_SIZENESW); } } if (Input.GetMouseButtonUp(1) && currentAction == CamAction.None) { if (!didShowHint && (didShowHint = true)) { System.Threading.Tasks.Task.Run(() => WinAPI.MessageBox(IntPtr.Zero, "There is no desktop settings for Camera2, everything is done ingame!\n\nYou can drag around a cameras display with your mouse and resize it on the corners corner from the desktop.", "FYI", 0)); } //currentAction = CamAction.Menu; // For now lets not add this as it can result in unclear circumstances with scenes etc. //if(Input.GetKey(KeyCode.LeftControl)) { // var newCam = CamManager.AddNewCamera(); // newCam.settings.Save(); //} } void ProcessCamAction(bool finished) { var x = Input.mousePosition / new Vector2(Screen.width, Screen.height); if ((int)currentAction >= 2) { targetCam.SetPositionClamped( // We take the current configured position and set the view position to it + the cursor move delta x - mouseStartPos01, deltaSchemes[(int)currentAction - 2], // And only when the button was released, save it to the config to make it the new config value finished ); } GL.Clear(true, true, Color.black); if (finished) { currentAction = CamAction.None; } } if (possibleAction != CamAction.None) { // Drag handler / Resize if (Input.GetMouseButtonDown(0) && targetCam != null && currentAction == CamAction.None) { mouseStartPos01 = lastMousePos / new Vector2(Screen.width, Screen.height); currentAction = possibleAction; } if (currentAction == CamAction.None) { return; } bool released = !Input.GetMouseButton(0) || !targetCam.isActiveAndEnabled; ProcessCamAction(released); } }