So, I’ve been trying to make a webcam stream where the server sends a live stream from his webcam to the clients on the network. I’ve tried to write a code myself (I’m not very good at it), but for some reason it doesn’t work. Here it is:
#pragma strict
var webcamTexture : WebCamTexture;
var data : Color32[];
function OnServerInitialized() {
webcamTexture = WebCamTexture();
renderer.material.mainTexture = webcamTexture;
webcamTexture.Play();
data = new Color32[webcamTexture.width * webcamTexture.height];
}
function Update () {
webcamTexture.GetPixels32 (data);
}
function OnConnectedToServer() {
networkView.RPC ("WebcamStream", RPCMode.Others, data, webcamTexture);
webcamTexture.Play();
}
@RPC
function WebcamStream (data : Color32 [], webcamTexture: WebCamTexture) {
var newwebcamTexture: WebCamTexture = webcamTexture;
renderer.material.mainTexture = newwebcamTexture;
var newdata: Color32[] = data;
webcamTexture.GetPixels32 (newdata);
}
It just results in a blank screen on the client’s side. Any help will be much appreciated ![]()
Do you get any errors? You do know you can't just send textures using the inbuilt Networking
– Benproductions1There was a tutorial I saw, where the guy was able to send textures along the network (when the server clicked a button, the texture of a certain object changed in the whole network). The thing is I can't get that texture to be updated from the webcam display. What do you suggest I do?
– HestaCan you post the link to that tutorial?
– soJackyDev