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