private IEnumerator GetCam() { while (userCam == null && camController == null) { yield return(new WaitForSeconds(0.5f)); Console.WriteLine("Trying to find cam..."); userCam = GameObject.Find("TrackingVolume/UserCamera"); if (userCam != null) { camController = userCam.GetComponent <UserCameraController>(); } } Console.WriteLine("Camera found!"); }
public void Update() { UserCameraController cam = UserCameraController.Instance; if (Event.current.shift && Input.GetKeyDown(KeyCode.I)) { if (isCameraActive()) { cam.transform.localRotation = Quaternion.identity; //Reset to fix rotation "bug" cam.transform.localPosition = Vector3.zero; //Reset to fix rotation "bug" MiscReflections.SetCameraMode(0); return; } } if (isCameraActive()) { if (Input.GetKey(KeyCode.UpArrow)) { cam.transform.Translate(Vector3.forward * (Time.deltaTime * movSpeed), Space.Self); } if (Input.GetKey(KeyCode.DownArrow)) { cam.transform.Translate(Vector3.back * (Time.deltaTime * movSpeed), Space.Self); } if (Input.GetKey(KeyCode.LeftArrow)) { cam.transform.Rotate(0f, 10f * (Time.deltaTime * (-rotSpeed)), 0f); } if (Input.GetKey(KeyCode.RightArrow)) { cam.transform.Rotate(0f, 10f * (Time.deltaTime * rotSpeed), 0f); } if (Input.GetKey(KeyCode.E)) { cam.transform.Translate(Vector3.up * (Time.deltaTime * movSpeed)); } if (Input.GetKey(KeyCode.Q)) { cam.transform.Translate(Vector3.down * (Time.deltaTime * movSpeed)); } } }
private IEnumerator InitEnhancedCamera() { yield return(VRCUiManagerUtils.WaitForUiManagerInit()); // Grab Controller UserCameraController userCameraController = Resources.FindObjectsOfTypeAll <UserCameraController>()[0]; // Create Sprites Sprite zoomin_sprite = CreateSprite(ImageData.zoomin_image); Sprite zoomout_sprite = CreateSprite(ImageData.zoomout_image); Sprite cameraindicator_on_sprite = CreateSprite(ImageData.cameraindicator_on_image); Sprite cameraindicator_off_sprite = CreateSprite(ImageData.cameraindicator_off_image); // Zoom-In GameObject zoomInButton = GameObject.Instantiate(userCameraController.viewFinder.transform.Find("PhotoControls/Right_Filters").gameObject, userCameraController.viewFinder.transform); VRCSDK2.VRC_CustomTrigger.Create("Zoom-In", zoomInButton, () => { Camera cam = userCameraController.photoCamera.GetComponent <Camera>(); if ((cam.fieldOfView - 10) > 0) { cam.fieldOfView -= 10; } cam = userCameraController.videoCamera.GetComponent <Camera>(); if ((cam.fieldOfView - 10) > 0) { cam.fieldOfView -= 10; } userCameraController.speaker.PlayOneShot(userCameraController.buttonSound); }); SetButtonSprite(zoomInButton, zoomin_sprite); SetButtonIconScale(zoomInButton); SetButtonOffset(zoomInButton); // Zoom-Out GameObject zoomOutButton = GameObject.Instantiate(userCameraController.viewFinder.transform.Find("PhotoControls/Right_Extender").gameObject, userCameraController.viewFinder.transform); VRCSDK2.VRC_CustomTrigger.Create("Zoom-Out", zoomOutButton, () => { Camera cam = userCameraController.photoCamera.GetComponent <Camera>(); if ((cam.fieldOfView + 10) < 180) { cam.fieldOfView += 10; } cam = userCameraController.videoCamera.GetComponent <Camera>(); if ((cam.fieldOfView + 10) < 180) { cam.fieldOfView += 10; } userCameraController.speaker.PlayOneShot(userCameraController.buttonSound); }); SetButtonSprite(zoomOutButton, zoomout_sprite); SetButtonIconScale(zoomOutButton); SetButtonOffset(zoomOutButton); // Toggle Camera Indicator GameObject cameraHelper = userCameraController.photoCamera.transform.Find("camera_lens_mesh").gameObject; GameObject toggleCameraIndicatorButton = GameObject.Instantiate(userCameraController.viewFinder.transform.Find("PhotoControls/Right_Timer").gameObject, userCameraController.viewFinder.transform); VRCSDK2.VRC_CustomTrigger.Create("Camera Indicator", toggleCameraIndicatorButton, () => { cameraHelper.SetActive(!cameraHelper.activeSelf); if (cameraHelper.activeSelf) { SetButtonSprite(toggleCameraIndicatorButton, cameraindicator_on_sprite); } else { SetButtonSprite(toggleCameraIndicatorButton, cameraindicator_off_sprite); } userCameraController.speaker.PlayOneShot(userCameraController.buttonSound); }); SetButtonSprite(toggleCameraIndicatorButton, cameraindicator_on_sprite); SetButtonIconScale(toggleCameraIndicatorButton); SetButtonOffset(toggleCameraIndicatorButton); // Resize Camera Body Transform camera_body = userCameraController.viewFinder.transform.Find("camera_mesh/body"); camera_body.localPosition = camera_body.localPosition + new Vector3(-0.025f, 0, 0); camera_body.localScale = camera_body.localScale + new Vector3(0.8f, 0, 0); }