Question by
cyberscorpia_unity · Apr 03, 2020 at 03:56 PM ·
webcamip
I try to connect IP CAM to my UNITY
in the "https://answers.unity.com/questions/1151512/show-video-from-ip-camera-source.html?page=2&pageSize=5&sort=votes" post was this script but I see gray screen. I use the "IP WEBCAM" app to get the IP. I NEED HELP
using UnityEngine;
using System.Collections;
public class pot : MonoBehaviour
{
public string uri = "http://192.168.0.18:8080/video"; //url for example
public Texture2D cam;
public void Start()
{
cam = new Texture2D(1, 1, TextureFormat.RGB24, true);
StartCoroutine(Fetch());
}
public IEnumerator Fetch()
{
while (true)
{
Debug.Log("loading... " + Time.realtimeSinceStartup);
WWWForm form = new WWWForm();
WWW www = new WWW("http://192.168.0.18:8080/video");
yield return www;
if (!string.IsNullOrEmpty(www.error))
throw new UnityException(www.error);
www.LoadImageIntoTexture(cam);
}
}
public void OnGUI()
{
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), cam);
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612230427im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
WebCamDevice and WebCamTexture FPS 0 Answers
how can i take webcam resource that worked by another program at the same time 0 Answers
Distorted/blank screen when playing scene 0 Answers
How to set hosts IP 2 Answers
Error with webcam not being authorized 0 Answers