- Home /
webcamtexture urp
Does webcamtexture() work with URP? 2019.3.0 ??
Tried these sample scripts that work for Standard and for HDRP. Doesn't work for URP. Thank you in advance for insight and understanding of what's up.
Works Standard
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class WebCam : MonoBehaviour {
private Renderer rend;
void Start()
{
WebCamDevice[] devices = WebCamTexture.devices;
Debug.Log("Number of web cams connected: " + devices.Length);
rend = this.GetComponentInChildren<Renderer>();
WebCamTexture mycam = new WebCamTexture();
string camName = devices[0].name;
Debug.Log("The webcam name is " + camName);
mycam.deviceName = camName;
rend.material.mainTexture = mycam;
mycam.Play();
}
}
Works HDRP
using System.Collections; using System.Collections.Generic; using UnityEngine;
[RequireComponent(typeof(Renderer))] public class WebCam : MonoBehaviour {
public string targetProperty = "_BaseColorMap";
// Start is called before the first frame update
void Start()
{
var tex = new WebCamTexture();
GetComponent<Renderer>().material.SetTexture(targetProperty, tex);
tex.Play();
}
}
Your answer
Follow this Question
Related Questions
Can I use a capture card with WebCamTexture 0 Answers
WebCamTexture on a SpriteRenderer 2 Answers
webcamtexture makes unity 5 crash 1 Answer
How to get stereo webcam as Object texture? 0 Answers
Take photo from webcam (not grab frame from video stream) 0 Answers