Browse Source

增加宽高

胡佳骏 1 year ago
parent
commit
ba19cd9f7f
1 changed files with 5 additions and 3 deletions
  1. 5 3
      Samples~/SDK/XRRGBCamera.cs

+ 5 - 3
Samples~/SDK/XRRGBCamera.cs

@@ -7,6 +7,7 @@ using SC.XR.Unity;
 
 public class XRRGBCamera : SingletonMono<XRRGBCamera>
 {
+    public bool isAuto=true;
     public static XRRGBCamera Instance;
     public Texture CaptureImage;
     public WebCamTexture RGBCamTexture;
@@ -17,10 +18,11 @@ public class XRRGBCamera : SingletonMono<XRRGBCamera>
     private void Start()
     {
         // 获取可用的摄像头设备
-        playCamera();
+        if(isAuto)
+        playCamera(w,h);
     }
 
-    public void playCamera()
+    public void playCamera(int w, int h)
     {
         if (RGBCamTexture != null && RGBCamTexture.isPlaying)
         {
@@ -37,7 +39,7 @@ public class XRRGBCamera : SingletonMono<XRRGBCamera>
         }
 
         // 使用第一个可用的摄像头设备(你可以根据需要选择其他设备)
-        RGBCamTexture = new WebCamTexture(devices[0].name, 1280, 720, 30);
+        RGBCamTexture = new WebCamTexture(devices[0].name, w, h, 30);
         Debug.Log("开启摄像头" + devices[0].name);
         // 开始摄像头捕捉
         RGBCamTexture.Play();