public static VRCT_Trigger CreateVRCT_Trigger(GameObject parent, Action onInteract) { VRCT_Trigger t = parent.AddComponent <VRCT_Trigger>(); TriggerEvent te = new TriggerEvent(); te.Name = "triggerButton"; te.BroadcastType = VRC_EventHandler.VrcBroadcastType.Local; te.AfterSeconds = 0f; te.TriggerType = TriggerType.OnInteract; t.Triggers.Add(te); t.onInteract += onInteract; return(t); }
// Deprecated as the camera as been modified private void InitEnhancedCamera() { //_Application/TrackingVolume/UserCamera/ViewFinder/PhotoCamera/Cylinder //_Application/TrackingVolume/UserCamera/ViewFinder/PhotoCamera/Cylinder (1) //cameraHelper[0] = UserCameraController.Instance.viewFinder.transform.Find("PhotoCamera/Cylinder").gameObject; //cameraHelper[1] = UserCameraController.Instance.viewFinder.transform.Find("PhotoCamera/Cylinder (1)").gameObject; // ZOOM IN GameObject zoomInButton = GameObject.CreatePrimitive(PrimitiveType.Cube); zoomInButton.transform.SetParent(UserCameraController.Instance.viewFinder.transform); zoomInButton.transform.localRotation = Quaternion.identity; zoomInButton.transform.localPosition = new Vector3(-0.22f, 0, -0.045f); zoomInButton.transform.localScale = new Vector3(0.03f, 0.01f, 0.03f); zoomInButton.GetComponent <Collider>().isTrigger = true; zoomInButton.GetComponent <Renderer>().material.color = Color.cyan * 0.8f; //zoomInButton.layer = cameraHelper[0].layer; VRCT_Trigger zoomInTrigger = VRCT_Trigger.CreateVRCT_Trigger(zoomInButton, () => { Camera cam1 = UserCameraController.Instance.photoCamera.GetComponent <Camera>(); if (cam1.fieldOfView - 10 > 0) { cam1.fieldOfView -= 10; } Camera cam2 = UserCameraController.Instance.videoCamera.GetComponent <Camera>(); if (cam2.fieldOfView - 10 > 0) { cam2.fieldOfView -= 10; } UserCameraController.Instance.speaker.PlayOneShot(UserCameraController.Instance.buttonSound); }); zoomInTrigger.interactText = "Zoom in"; zoomInTrigger.proximity = 0.4f; // ZOOM OUT GameObject zoomOutButton = GameObject.CreatePrimitive(PrimitiveType.Cube); zoomOutButton.transform.SetParent(UserCameraController.Instance.viewFinder.transform); zoomOutButton.transform.localRotation = Quaternion.identity; zoomOutButton.transform.localPosition = new Vector3(-0.22f, 0, 0); zoomOutButton.transform.localScale = new Vector3(0.03f, 0.01f, 0.03f); zoomOutButton.GetComponent <Collider>().isTrigger = true; zoomOutButton.GetComponent <Renderer>().material.color = Color.magenta * 0.8f; //zoomOutButton.layer = cameraHelper[0].layer; VRCT_Trigger zoomOutTrigger = VRCT_Trigger.CreateVRCT_Trigger(zoomOutButton, () => { Camera cam1 = UserCameraController.Instance.photoCamera.GetComponent <Camera>(); if (cam1.fieldOfView + 10 < 180) { cam1.fieldOfView += 10; } Camera cam2 = UserCameraController.Instance.videoCamera.GetComponent <Camera>(); if (cam2.fieldOfView + 10 < 180) { cam2.fieldOfView += 10; } UserCameraController.Instance.speaker.PlayOneShot(UserCameraController.Instance.buttonSound); }); zoomOutTrigger.interactText = "Zoom out"; zoomOutTrigger.proximity = 0.4f; // CAMERA HELPER GameObject toggleCameraHelperButton = GameObject.CreatePrimitive(PrimitiveType.Cube); toggleCameraHelperButton.transform.SetParent(UserCameraController.Instance.viewFinder.transform); toggleCameraHelperButton.transform.localRotation = Quaternion.identity; toggleCameraHelperButton.transform.localPosition = new Vector3(-0.22f, 0, 0.045f); toggleCameraHelperButton.transform.localScale = new Vector3(0.03f, 0.01f, 0.03f); toggleCameraHelperButton.GetComponent <Collider>().isTrigger = true; toggleCameraHelperButton.GetComponent <Renderer>().material.color = Color.yellow * 0.8f; //toggleCameraHelperButton.layer = cameraHelper[0].layer; /* * VRCT_Trigger toggleCameraHelperTrigger = VRCT_Trigger.CreateVRCT_Trigger(toggleCameraHelperButton, () => { * cameraHelper[0].SetActive(!cameraHelper[0].activeSelf); * cameraHelper[1].SetActive(!cameraHelper[1].activeSelf); * UserCameraController.Instance.speaker.PlayOneShot(UserCameraController.Instance.buttonSound); * }); * * toggleCameraHelperTrigger.interactText = "Toggle camera helper"; * toggleCameraHelperTrigger.proximity = 0.4f; */ }