Hi, would it be possible to render a camera (pointed on a rotating object) to a Texture2D that would then be used by GUI.Drawtexture ? I've tried using RenderTexture, but how can I convert this to a usable Texture2D ? Basically I need to display the rotation of a 3D object over a UnityGUI interface (the normally is on top of anything else)... any other trick is welcome !
you can not convert render textures to texture2d, they are not compatible to each other (rendertexture exists only on graphics ram, texture2d is a system ram thing that also exists on the gpu). That being said, GUI.DrawTexture expects a Texture, not a Texture2D so thats no problem cause Texture2D as well as RenderTexture extend from Texture
OK, then.... is there a trick so that I can take a view from a camera and display that view on a GUI thing ? (for example it could be a rear view mirror in a car you're driving....
just draw the rendertexture. As mentioned, DrawTexture does not need a Texture2D, it needs a Texture and RenderTexture as well as Texture2D are both fine when only Texture is required
Ummm...... how can you draw the rendertexture ? I know how to display things with UnityGUI, texture over 3D meshes... is there a third way ? if yes, then code please.... (at least 1 line !)
You just need to call GUI.DrawTexture passing a RenderTexture in place of a Texture2D. The function expects a Texture object, which is the superclass of both RenderTexture and Texture2D, so they are both compatible.