胡佳骏 1 year ago
parent
commit
4fcd2ee18f
1 changed files with 6 additions and 6 deletions
  1. 6 6
      Samples~/SDK/XRRGBCamera.cs

+ 6 - 6
Samples~/SDK/XRRGBCamera.cs

@@ -18,10 +18,10 @@ public class XRRGBCamera : SingletonMono<XRRGBCamera>
     private void Start()
     {
         // 获取可用的摄像头设备
-        playCamera();
+        //playCamera(1280,720);
     }
 
-    public void playCamera()
+    public void playCamera(int w, int h)
     {
         if (RGBCamTexture != null && RGBCamTexture.isPlaying)
         {
@@ -39,21 +39,21 @@ public class XRRGBCamera : SingletonMono<XRRGBCamera>
 
 #if UNITY_EDITOR
         // 使用第一个可用的摄像头设备(你可以根据需要选择其他设备)
-        RGBCamTexture = new WebCamTexture(devices[0].name, 1280, 720, 30);
+        RGBCamTexture = new WebCamTexture(devices[0].name, w, h, 30);
         Debug.Log("开启摄像头" + devices[0].name);
 #else
         // 使用第一个可用的摄像头设备(你可以根据需要选择其他设备)
-        RGBCamTexture = new WebCamTexture(devices[2].name, 1280, 720, 30);
+        RGBCamTexture = new WebCamTexture(devices[2].name, w, h, 30);
         Debug.Log("开启摄像头" + devices[2].name);
 #endif
 
         // 开始摄像头捕捉
         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)
         {