Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c579bf5

Browse files
committed
script to display webcam texture into a gameobject
1 parent 4fd9646 commit c579bf5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /