How to display a texture2D onto a Canvas?

I am capturing some pixels from the screen on a click event on an object in the world and want to display them on a GUI canvas I have sitting in the world. What is the best way to do this in scripting?

I can’t seem to figure out which component to access, or add to the canvas in order to stick my texture2D there.

You can just use the RawImage component to draw a texture2D to the canvas.
http://docs.unity3d.com/ScriptReference/UI.RawImage.html
Or you can use Sprite.Create() to generate a sprite from a texture2D and display it via the image component.

3 Likes