- Home /
Using Photon to Send Screenshot to other Players
I am working on a game, where I want a player on one device to take a screenshot, and assign as a texture to a gameobject, and both devices in the game (connected by photon), see the updated picture. My script works with the screenshot part, but it only displays the screenshot of its own device, instead of the other one. I have spent almost 2 days working on it, and I can't get it. Is it even possible?
Is there a way to create a new texture on one device, then send it to another device to use? :)
Here is my script so far, please help:
using System; using UnityEngine; using System.Collections;
public class test : Photon.MonoBehaviour { public Texture onetex; public Texture twotex; public byte[] byte_me; public GameObject sphere_object;
public void sendimage() {
if (this.photonView) {
this.photonView.RPC ("ChangeTextureNow", PhotonTargets.All);
}
}
}
[PunRPC]
void ChangeTextureNow () {
int width = Screen.width;
int height = Screen.height;
Texture2D tex = new Texture2D (width, height, TextureFormat.RGB24, false);
tex.ReadPixels (new Rect (0, 0, width, height), 0, 0);
tex.Apply ();
byte_me = tex.EncodeToJPG ();
Texture2D tat = new Texture2D (2, 2);
tat.LoadImage(byte_me);
sphere_object.renderer.material.mainTexture = tat;
}
}
Have you fixed it yet? I am having the same exact problem...