Better way to edit RawImage texture data?,Better way to edit a RawImage texture?
Currently our method for editing the underlying texture of a raw image (note not changing which texture, but directly editing the pixels) is as follows:
 // Create a series of variables
 private RawImage mRawImage;
 private Texture mTexture;
 private Texture2D mTexture2D;
 private RenderTexture mRenderTexture;
 
 //Get the RawImageTexture:
 mRawImage = GetComponent<RawImage>();
 
 // In the Update function do this awful monstrosity:
 Destroy(mTexture2D);
 Destroy(mRenderTexture);
 mTexture = mRawImage.texture;
 mTexture2d = new Texture2D(mTexture.width, mTexture.height, TextureFormat.RGBA32, false);
 mRenderTexture = new RenderTexture(mTexture.width, mTexture.height, 32);
 Graphics.Blit(mTexture, mRenderTexture);
 RenderTexture.active = mRenderTexture;
 mTexture2D.ReadPixels(new Rect(0,0, mRenderTexture.width, mRenderTexture.height),0,0);
 
 // do what ever pixel modifications you want, then:
 mTexture2d.Apply();
 GetComponent<RawImage>().texture = mTexture2D;
 
Now obviously this is pretty hideous and resource intensive so surely there has to be a better way of doing it.
- There is no obvious way to access the pixel data from a RawImage. 
- Texture to Texture2D casting doesn't actually really work but RawImage claims to handle a texture 
- Trying to overwrite the mRenderTexture and mTexture2D during the update so you don't have to call new twice a frame, doesn't work. 
- I just want to edit a UI element in real time, surely that's not the most uncommon request ever? 
I would really appreciate if anyone has any input on this because I have googled till the cows come home and read all of the documentation (it was not super helpful) and this is the best we can get. Cheers.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                