using System; using System.Collections.Generic; using UnityEngine; namespace VRUIP { public class CameraVR : A_Canvas { [SerializeField] private Camera unityCamera; [SerializeField] private Picture picturePrefab; [SerializeField] private Transform imageSpawnLocation; private List _pictures; private int _depthIndex = 0; public bool IsSelfie => Math.Abs(unityCamera.transform.localEulerAngles.y - 180) < 0.1; /// /// Flip this camera to selfie or front. /// public void FlipCamera() { unityCamera.transform.localEulerAngles = IsSelfie ? new Vector3(0, 0, 0) : new Vector3(0, 180, 0); } /// /// Snap a picture with this Camera. /// public void SnapPicture() { var cameraTexture = Util.ToTexture2D(unityCamera.targetTexture); var sprite = Util.ToSprite(cameraTexture); picturePrefab.Create(imageSpawnLocation, sprite); } /// /// Zoom In. /// public void ZoomIn() { if (_depthIndex < 2) { _depthIndex++; unityCamera.fieldOfView -= 10; } } /// /// Zoom out. /// public void ZoomOut() { if (_depthIndex > -2) { _depthIndex--; unityCamera.fieldOfView += 10; } } protected override void SetColors(ColorTheme theme) { //Nothing here for now. } } }