We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4fd9646 commit c579bf5Copy full SHA for c579bf5
Assets/Scripts/Texture/WebCamDisplay.cs
@@ -0,0 +1,21 @@
1
+using System.Collections;
2
+using System.Collections.Generic;
3
+using UnityEngine;
4
+
5
+// usage: attach this script to any gameobject in which you want to render the webcam display
6
+// create a material, use Unlit/Texture as a shader and place it to the gameobject's material placeholder in the mesh renderer component
7
8
+namespace UnityLibrary
9
+{
10
+ public class WebCamDisplay : MonoBehaviour
11
+ {
12
+ void Start()
13
14
+ WebCamTexture webCam = new WebCamTexture();
15
+ webCam.deviceName = WebCamTexture.devices[0].name;
16
+ this.GetComponent<MeshRenderer>().material.mainTexture = webCam;
17
+ webCam.Play();
18
+ }
19
20
+}
21
0 commit comments