Search code examples
scrollunity-game-enginetexture2d

Scrolling a Texture2D that is in a RawImage?


Is this possible with Unity3D? ...

I have a Texture2D in a RawImage that is used to display on a UI Canvas and pixels are drawn into it with SetPixel() and then I want to scroll the Texture2D pixel by pixel. I don't want to use any material or fancy stuff as this code should be very efficient and lightweight. Can this be done somehow?


Solution

  • I ended up creating a wrapper class for Texture2D that adds API to better work with pixel manipulation tasks. It still all uses GetPixels/SetPixels since there isn't really much more API than that in Unity3D currently. But it's better than nothing. If anyone has a better method or suggestions it would be cool if you can share them.

    Here's the class named Bitmap2D https://gist.github.com/hexagonstar/be39f847a4840c838500