Hi there,
I’ve been attempting to connect my Z1 camera with Unity, but unfortunately, I’ve hit a snag.
I’m currently using Unity version 2022.3.17f1 along with the 3.0.0 UVC driver.
Interestingly, I’ve had no issues connecting the camera to OBS. However, whenever I attempt to do the same in Unity, the program crashes without displaying any error messages. I’ve tested my code with various other cameras, and it seems to function properly.
I’ll provide the code below for reference:
using UnityEngine;
public class getRicohStream : MonoBehaviour
{
void Start()
{
WebCamDevice[] devices = WebCamTexture.devices;
//printing out all video sources for debugging purposes
Debug.Log("Number of web cams connected: " + devices.Length);
for (int i = 0; i < devices.Length; i++)
{
Debug.Log(i + " " + devices[i].name);
}
Renderer rend = this.GetComponentInChildren<Renderer>();
WebCamTexture mycam = new();
string camName = devices[0].name;
mycam.deviceName = camName;
Debug.Log("The camera name is: " + camName);
rend.material.mainTexture = mycam;
mycam.Play();
}
}
Thank you for your assistance.