|
@@ -22,6 +22,10 @@ public class XRRGBCamera : SingletonMono<XRRGBCamera>
|
|
|
|
|
|
public void playCamera()
|
|
|
{
|
|
|
+ if (RGBCamTexture != null && RGBCamTexture.isPlaying)
|
|
|
+ {
|
|
|
+ RGBCamTexture.Stop();
|
|
|
+ }
|
|
|
|
|
|
|
|
|
WebCamDevice[] devices = WebCamTexture.devices;
|
|
@@ -38,10 +42,15 @@ public class XRRGBCamera : SingletonMono<XRRGBCamera>
|
|
|
|
|
|
RGBCamTexture.Play();
|
|
|
CaptureImage = RGBCamTexture;
|
|
|
- if (this.GetComponent<RawImage>()!=null)
|
|
|
+ if (this.GetComponent<RawImage>() != null)
|
|
|
{
|
|
|
this.GetComponent<RawImage>().texture = CaptureImage;
|
|
|
- this.GetComponent<RawImage>().transform.localEulerAngles = new Vector3(0,0,0);
|
|
|
+ this.GetComponent<RawImage>().transform.localEulerAngles = new Vector3(0, 0, 0);
|
|
|
+ }
|
|
|
+ if (this.GetComponent<MeshRenderer>() != null)
|
|
|
+ {
|
|
|
+ this.GetComponent<MeshRenderer>().material.mainTexture = CaptureImage;
|
|
|
+ this.GetComponent<MeshRenderer>().transform.localEulerAngles = new Vector3(0, 0, 0);
|
|
|
}
|
|
|
Debug.Log("开启摄像头");
|
|
|
}
|
|
@@ -52,7 +61,9 @@ public class XRRGBCamera : SingletonMono<XRRGBCamera>
|
|
|
|
|
|
public void stopCamera()
|
|
|
{
|
|
|
-
|
|
|
- RGBCamTexture.Stop();
|
|
|
+ if (RGBCamTexture != null && RGBCamTexture.isPlaying)
|
|
|
+ {
|
|
|
+ RGBCamTexture.Stop();
|
|
|
+ }
|
|
|
}
|
|
|
}
|