Skip to content

Instantly share code, notes, and snippets.

@smartium
Created April 19, 2022 21:26
Show Gist options
  • Select an option

  • Save smartium/8007c5fcae92d8e54fe8ce9f0152185f to your computer and use it in GitHub Desktop.

Select an option

Save smartium/8007c5fcae92d8e54fe8ce9f0152185f to your computer and use it in GitHub Desktop.

Revisions

  1. SMARTIUM created this gist Apr 19, 2022.
    23 changes: 23 additions & 0 deletions List and Set Camera Device in Unity3D.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    WebCamTexture webCamTexture;
    WebCamDevice[] devices;

    // List devices
    devices = WebCamTexture.devices;
    for (int i = 0; i < devices.Length; i++)
    Debug.Log(devices[i].name);

    // Configure WebCam
    webCamTexture = new WebCamTexture(1280, 720, 30);

    // Set device
    webCamTexture.deviceName = devices[1].name;

    // Start webcam
    webCamTexture.Play();

    // Create and display the destination segmentation image
    while (webCamTexture.width == 16 || webCamTexture.height == 16)
    await Task.Yield();

    // Display webcam
    visualizer.Render(webCamTexture);