Hi everybody,
I have a problem.
I wrote a previous post about rescaling a Texture2D.
Scenario:
(Server) Get frames from camera, assign them to a Texture2D, rescale the Texture2D, convert to byte and send it over the network.
(Client) Load byte into a texture, assign it to RawImage.texture.
Thanks to a previous question I was able to rescale (bilinear) the texture and send it. The problem now is that, after load the byte to a Texture2D on client side, I get this texture. Can someone detect what is the problem?
Server Code (in update function):
void Start()
{
texture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false); // screen size ! Screen.width
tex2 = new Texture2D(160, 120, TextureFormat.RGB24, false); // screen size !
}
void Update() {
// do some stuff for get frames on texture
filter = ImageFilterMode.Biliner;
tex2 = ResizeTextureAlgorithm(texture, filter, 0.1f);
bckCam_copy.texture = tex2;
bckCam_copy.material.mainTexture = tex2;
pixelsToSend = tex2.GetRawTextureData();
}
Client Code (in update function):
void Start()
{
tex = new Texture2D(128, 72, TextureFormat.RGB24, false);
}
void Update()
{
if (rawData.Length > 0)
{
tex.LoadRawTextureData(rawData);
tex.Apply();
rawImage.material.mainTexture = tex;
rawImage.texture = tex;
}
}