Skip to content

Instantly share code, notes, and snippets.

@rkandas
Last active April 18, 2020 13:44
Show Gist options
  • Save rkandas/9a7e62ea2fe6119d03dcbcaf6dc9ce26 to your computer and use it in GitHub Desktop.
Save rkandas/9a7e62ea2fe6119d03dcbcaf6dc9ce26 to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEngine.UI;
public class WebCamPlayer : MonoBehaviour
{
[SerializeField] public RawImage rawimage;
private WebCamTexture webcamTexture;
void Start ()
{
if (rawimage != null)
{
webcamTexture = new WebCamTexture(1080,1920,30);
rawimage.texture = webcamTexture;
rawimage.material.mainTexture = webcamTexture;
webcamTexture.Play();
}
else
{
Debug.LogError("RawImage not set");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment