123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using NRKernal;
- using SC.XR.Unity;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class XRRGBCamera : SingletonMono<XRRGBCamera>
- {
- public Texture CaptureImage;
- NRRGBCamTexture RGBCamTexture;
- public bool isAuto = true;
- private void Start()
- {
- RGBCamTexture = new NRRGBCamTexture();
- if (isAuto)
- playCamera(1280, 720);
- }
- public void playCamera(int w, int h)
- {
- if (RGBCamTexture != null)
- {
- RGBCamTexture.Stop();
- }
- CaptureImage = RGBCamTexture.GetTexture();
- if (this.GetComponent<RawImage>() != null)
- {
- this.GetComponent<RawImage>().texture = CaptureImage;
- this.GetComponent<RawImage>().transform.localEulerAngles = new Vector3(-180, 0, 0);
- }
- if (this.GetComponent<MeshRenderer>() != null)
- {
- this.GetComponent<MeshRenderer>().material.mainTexture = CaptureImage;
- this.GetComponent<MeshRenderer>().transform.localEulerAngles = new Vector3(-180, 0, 0);
- }
- RGBCamTexture.Play();
- }
- public void stopCamera()
- {
- if (RGBCamTexture != null)
- {
- RGBCamTexture.Stop();
- }
- }
- }
|