I want send my texture to other Client.
I use a code for RenderTexture and Works Nice!
and change that to use for Texture2D But Client see a textrue from one side of my camera or nothing!
public Texture2D MyTexture;
public byte[] receivedBytes;
public byte[] N;
public Texture2D texi;
void Start () {
texi = new Texture2D(MyTexture.width,MyTexture.height);
}
void Update () {
if(Network.isServer){
if(Input.GetKeyDown(KeyCode.X)){
StartCoroutine(GetRenderTexturePixel(MyTexture));
networkView.RPC("Send", RPCMode.All,N);
}
}
if(Network.isClient){
if(Input.GetKeyDown(KeyCode.X)){
texi.LoadImage(N);
renderer.material.mainTexture = texi;
}
}
}
IEnumerator GetRenderTexturePixel(Texture2D tex)
{
Texture2D tempTex = new Texture2D(tex.width, tex.height);
yield return new WaitForEndOfFrame();
tempTex.ReadPixels(new Rect(0, 0, tex.width, tex.height), 0, 0);
tempTex.Apply();
N= tempTex.EncodeToPNG();
}
[RPC]
public void Send(byte[] receivedByte){
receivedBytes=receivedByte;
}