// This is a mess please don't look // and also pull request to improve it thx public override void OnUpdate() { // Testing /*if (Input.GetKeyDown(KeyCode.F1)) { * MelonLogger.Msg("test"); * var viewFinder = CameraUtils.GetPinsHolder().transform.Find("button-Pin-1"); * var components = viewFinder.GetComponents<Component>(); * for (int i = 0; i < components.Length; i++) { * var component = components[i]; * MelonLogger.Msg(i + " - " + component.name + " - " + component.GetIl2CppType().Name); * } * var childCount = viewFinder.transform.childCount; * for (int i = 0; i < childCount; i++) { * var child = viewFinder.transform.GetChild(i); * MelonLogger.Log(child.name + " - " + child.GetIl2CppType().Name); * } * }*/ if (Settings.cameraEnabled && Settings.arrowKeysEnabled) { var cameraRotation = CameraUtils.worldCameraQuaternion.ToEuler(); var actualCameraSpeed = (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? CameraSpeedAlt : CameraSpeed; if (Input.GetKey(KeyCode.DownArrow)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { if (Settings.rotateAroundUserCamera) { CameraUtils.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.up, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f); } else { CameraUtils.worldCameraVector -= new Vector3( (float)Math.Sin(cameraRotation.y) * actualCameraSpeed, 0f, (float)Math.Cos(cameraRotation.y) * actualCameraSpeed); } } } else { CameraUtils.GetViewFinder().transform.localPosition += new Vector3(0f, 0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -0.01f : -0.005f); } } if (Input.GetKey(KeyCode.UpArrow)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { if (Settings.rotateAroundUserCamera) { CameraUtils.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.up, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f); } else { CameraUtils.worldCameraVector += new Vector3( (float)Math.Sin(cameraRotation.y) * actualCameraSpeed, 0f, (float)Math.Cos(cameraRotation.y) * actualCameraSpeed); } } } else { CameraUtils.GetViewFinder().transform.localPosition += new Vector3(0f, 0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 0.01f : 0.005f); } } if (Input.GetKey(KeyCode.PageUp)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { if (Settings.rotateAroundUserCamera) { CameraUtils.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.right, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f); } else { CameraUtils.worldCameraVector += new Vector3(0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? CameraSpeedAlt : CameraSpeed, 0f); } } } else { if (Settings.rotateAroundUserCamera) { CameraUtils.GetViewFinder().transform.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.right, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f); } else { CameraUtils.GetViewFinder().transform.localPosition += new Vector3(0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 0.01f : 0.005f, 0f); } } } if (Input.GetKey(KeyCode.PageDown)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { if (Settings.rotateAroundUserCamera) { CameraUtils.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.right, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f); } else { CameraUtils.worldCameraVector += new Vector3(0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -CameraSpeedAlt : -CameraSpeed, 0f); } } } else { if (Settings.rotateAroundUserCamera) { CameraUtils.GetViewFinder().transform.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.right, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f); } else { CameraUtils.GetViewFinder().transform.localPosition += new Vector3(0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -0.01f : -0.005f, 0f); } } } if (Input.GetKey(KeyCode.LeftArrow)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { CameraUtils.worldCameraVector -= new Vector3( (float)Math.Cos(cameraRotation.y) * actualCameraSpeed, 0f, (float)-Math.Sin(cameraRotation.y) * actualCameraSpeed); } } else { if (Settings.rotateAroundUserCamera) { CameraUtils.GetViewFinder().transform.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.up, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f); } else { CameraUtils.GetViewFinder().transform.localPosition += new Vector3((Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -0.01f : -0.005f, 0f, 0f); } } } if (Input.GetKey(KeyCode.RightArrow)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { CameraUtils.worldCameraVector += new Vector3( (float)Math.Cos(cameraRotation.y) * actualCameraSpeed, 0f, (float)-Math.Sin(cameraRotation.y) * actualCameraSpeed); } } else { if (Settings.rotateAroundUserCamera) { CameraUtils.GetViewFinder().transform.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.up, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f); } else { CameraUtils.GetViewFinder().transform.localPosition += new Vector3((Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 0.01f : 0.005f, 0f, 0f); } } } // Rotation if (Input.GetKey(KeyCode.Keypad8)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { CameraUtils.worldCameraQuaternion *= Quaternion.Euler(Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) ? -2f : -1f, 0f, 0f); } } else { CameraUtils.GetViewFinder().transform.Rotate(new Vector3((Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f, 0f)); } } if (Input.GetKey(KeyCode.Keypad2)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { CameraUtils.worldCameraQuaternion *= Quaternion.Euler(Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) ? 2f : 1f, 0f, 0f); } } else { CameraUtils.GetViewFinder().transform.Rotate(new Vector3((Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f, 0f)); } } if (Input.GetKey(KeyCode.Keypad4)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { CameraUtils.worldCameraQuaternion *= Quaternion.Euler(0f, Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) ? -2f : -1f, 0f); } } else { CameraUtils.GetViewFinder().transform.Rotate(new Vector3(0f, 0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f)); } } if (Input.GetKey(KeyCode.Keypad6)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { CameraUtils.worldCameraQuaternion *= Quaternion.Euler(0f, Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) ? 2f : 1f, 0f); } } else { CameraUtils.GetViewFinder().transform.Rotate(new Vector3(0f, 0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f)); } } if (Input.GetKey(KeyCode.Keypad7)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { CameraUtils.worldCameraQuaternion *= Quaternion.Euler(0f, 0f, Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) ? 2f : 1f); } } else { CameraUtils.GetViewFinder().transform.Rotate(new Vector3(0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f, 0f)); } } if (Input.GetKey(KeyCode.Keypad9)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { CameraUtils.worldCameraQuaternion *= Quaternion.Euler(0f, 0f, Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) ? -2f : -1f); } } else { CameraUtils.GetViewFinder().transform.Rotate(new Vector3(0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f, 0f)); } } // Reset if (Input.GetKeyDown(KeyCode.Keypad3)) { if (Settings.cameraEnabled) { CameraUtils.ResetCamera(); } } // Look at player if (Input.GetKeyDown(KeyCode.Keypad1)) { if (Settings.cameraEnabled) { CameraUtils.GetViewFinder().transform.LookAt(VRCUtils.GetMainCamera().transform); CameraUtils.GetViewFinder().transform.rotation *= Quaternion.Euler(90f, 0f, 0f); } } // Take pic if (Input.GetKeyDown(KeyCode.KeypadPlus)) { if (Settings.cameraEnabled) { CameraUtils.TakePicture(0); } } // Toggle camera movement if (Input.GetKeyDown(KeyCode.KeypadMinus)) { if (Settings.cameraEnabled) { if (cameraMovementButton != null) { Settings.moveCamera = !Settings.moveCamera; cameraMovementButton.setText("Camera\nMovement\n<color=#ff73fa>" + (Settings.moveCamera ? "Camera" : "Viewer") + "</color>"); VRCUtils.QueueHudMessage("Camera Movement set to " + (Settings.moveCamera ? "Camera" : "Viewer")); } } } } }
// This is a mess please don't look // and also pull request to improve it thx public override void OnUpdate() { // Testing /* if (Input.GetKeyDown(KeyCode.F1)) { * var quickMenu = VRCUtils.GetQuickMenu(); * var cameraMenu = quickMenu.transform.Find("CameraMenu"); * VRCUtils.ShowQuickMenuPage(quickMenu, cameraMenu); * * var smoothCameraButton = cameraMenu.Find("SmoothFPVCamera"); * smoothCameraButton.gameObject.SetActive(true); * * var photoModeButton = cameraMenu.Find("PhotoMode"); * photoModeButton.gameObject.SetActive(true); * * var videoModeButton = cameraMenu.Find("VideoMode"); * videoModeButton.gameObject.SetActive(true); * * var disableCameraButton = cameraMenu.Find("DisableCamera"); * disableCameraButton.gameObject.SetActive(true); * } */ if (Settings.cameraEnabled && Settings.arrowKeysEnabled) { var cameraRotation = CameraUtils.worldCameraQuaternion.ToEuler(); var actualCameraSpeed = (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? CameraSpeedAlt : CameraSpeed; if (Input.GetKey(KeyCode.DownArrow)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { if (Settings.rotateAroundUserCamera) { CameraUtils.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.up, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f); } else { CameraUtils.worldCameraVector -= new Vector3( (float)Math.Sin(cameraRotation.y) * actualCameraSpeed, 0f, (float)Math.Cos(cameraRotation.y) * actualCameraSpeed); } } } else { VRCUtils.GetUserCameraController().viewFinder.transform.localPosition += new Vector3(0f, 0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -0.01f : -0.005f); } } if (Input.GetKey(KeyCode.UpArrow)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { if (Settings.rotateAroundUserCamera) { CameraUtils.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.up, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f); } else { CameraUtils.worldCameraVector += new Vector3( (float)Math.Sin(cameraRotation.y) * actualCameraSpeed, 0f, (float)Math.Cos(cameraRotation.y) * actualCameraSpeed); } } } else { VRCUtils.GetUserCameraController().viewFinder.transform.localPosition += new Vector3(0f, 0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 0.01f : 0.005f); } } if (Input.GetKey(KeyCode.PageUp)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { if (Settings.rotateAroundUserCamera) { CameraUtils.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.right, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f); } else { CameraUtils.worldCameraVector += new Vector3(0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? CameraSpeedAlt : CameraSpeed, 0f); } } } else { if (Settings.rotateAroundUserCamera) { VRCUtils.GetUserCameraController().viewFinder.transform.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.right, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f); } else { VRCUtils.GetUserCameraController().viewFinder.transform.localPosition += new Vector3(0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 0.01f : 0.005f, 0f); } } } if (Input.GetKey(KeyCode.PageDown)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { if (Settings.rotateAroundUserCamera) { CameraUtils.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.right, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f); } else { CameraUtils.worldCameraVector += new Vector3(0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -CameraSpeedAlt : -CameraSpeed, 0f); } } } else { if (Settings.rotateAroundUserCamera) { VRCUtils.GetUserCameraController().viewFinder.transform.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.right, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f); } else { VRCUtils.GetUserCameraController().viewFinder.transform.localPosition += new Vector3(0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -0.01f : -0.005f, 0f); } } } if (Input.GetKey(KeyCode.LeftArrow)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { CameraUtils.worldCameraVector -= new Vector3( (float)Math.Cos(cameraRotation.y) * actualCameraSpeed, 0f, (float)-Math.Sin(cameraRotation.y) * actualCameraSpeed); } } else { if (Settings.rotateAroundUserCamera) { VRCUtils.GetUserCameraController().viewFinder.transform.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.up, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f); } else { VRCUtils.GetUserCameraController().viewFinder.transform.localPosition += new Vector3((Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -0.01f : -0.005f, 0f, 0f); } } } if (Input.GetKey(KeyCode.RightArrow)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { CameraUtils.worldCameraVector += new Vector3( (float)Math.Cos(cameraRotation.y) * actualCameraSpeed, 0f, (float)-Math.Sin(cameraRotation.y) * actualCameraSpeed); } } else { if (Settings.rotateAroundUserCamera) { VRCUtils.GetUserCameraController().viewFinder.transform.RotateAround(VRCUtils.GetMainCamera().transform.position, VRCUtils.GetMainCamera().transform.up, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f); } else { VRCUtils.GetUserCameraController().viewFinder.transform.localPosition += new Vector3((Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 0.01f : 0.005f, 0f, 0f); } } } // Rotation if (Input.GetKey(KeyCode.Keypad8)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { CameraUtils.worldCameraQuaternion *= Quaternion.Euler(Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) ? -2f : -1f, 0f, 0f); } } else { VRCUtils.GetUserCameraController().viewFinder.transform.Rotate(new Vector3((Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f, 0f)); } } if (Input.GetKey(KeyCode.Keypad2)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { CameraUtils.worldCameraQuaternion *= Quaternion.Euler(Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) ? 2f : 1f, 0f, 0f); } } else { VRCUtils.GetUserCameraController().viewFinder.transform.Rotate(new Vector3((Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f, 0f)); } } if (Input.GetKey(KeyCode.Keypad4)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { CameraUtils.worldCameraQuaternion *= Quaternion.Euler(0f, Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) ? -2f : -1f, 0f); } } else { VRCUtils.GetUserCameraController().viewFinder.transform.Rotate(new Vector3(0f, 0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f)); } } if (Input.GetKey(KeyCode.Keypad6)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { CameraUtils.worldCameraQuaternion *= Quaternion.Euler(0f, Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) ? 2f : 1f, 0f); } } else { VRCUtils.GetUserCameraController().viewFinder.transform.Rotate(new Vector3(0f, 0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f)); } } if (Input.GetKey(KeyCode.Keypad7)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { CameraUtils.worldCameraQuaternion *= Quaternion.Euler(0f, 0f, Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) ? 2f : 1f); } } else { VRCUtils.GetUserCameraController().viewFinder.transform.Rotate(new Vector3(0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? -2f : -1f, 0f)); } } if (Input.GetKey(KeyCode.Keypad9)) { if (Settings.moveCamera) { if (Settings.allowCameraMovement) { CameraUtils.worldCameraQuaternion *= Quaternion.Euler(0f, 0f, Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) ? -2f : -1f); } } else { VRCUtils.GetUserCameraController().viewFinder.transform.Rotate(new Vector3(0f, (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) ? 2f : 1f, 0f)); } } // Reset if (Input.GetKeyDown(KeyCode.Keypad3)) { if (Settings.cameraEnabled) { CameraUtils.ResetCamera(); } } // Look at player if (Input.GetKeyDown(KeyCode.Keypad1)) { if (Settings.cameraEnabled) { VRCUtils.GetUserCameraController().viewFinder.transform.LookAt(VRCUtils.GetMainCamera().transform); VRCUtils.GetUserCameraController().viewFinder.transform.rotation *= Quaternion.Euler(90f, 0f, 0f); } } // Take pic if (Input.GetKeyDown(KeyCode.KeypadPlus)) { if (Settings.cameraEnabled) { CameraUtils.TakePicture(0); } } // Toggle camera movement if (Input.GetKeyDown(KeyCode.KeypadMinus)) { if (Settings.cameraEnabled) { if (cameraMovementButton != null) { Settings.moveCamera = !Settings.moveCamera; cameraMovementButton.setText("Camera\nMovement\n<color=#845bff>" + (Settings.moveCamera ? "Camera" : "Viewer") + "</color>"); VRCUtils.QueueHudMessage("Camera Movement set to " + (Settings.moveCamera ? "Camera" : "Viewer")); } } } } }