Question on Layers

http://forum.unity3d.com/viewtopic.php?t=7689&highlight=background+image

I was reading this post and trying to do what Yoggy suggests but i’m having some issues.

I want draw an image as the background for my game using GUI.Label. I want my models to be drawn above it. So i’ve setup a game_objects layer and a background layer. I got 2 cameras to render each layer. But no matter what the GUI.Label is alwasy being drawn on top. I’ve attached my project to this post.

My scripting level is noob, so the script is taken from the 3D platformer tutorial :slight_smile:

60568–2216–$unity_help_903.rar (545 KB)

Yep, that’s the way it works. The new GUI system is fantastic for doing complicated user interfaces relatively easily, but GUITextures are generally better for game-oriented 2D imagery.

–Eric

Sorry, but can you show me example how to use GUI.DrawTexture?

So with GUI.DrawTexture and layers I can get it to draw behind my 3d models?

thanks

No, you don’t want to use the GUI coding system at all in this case, since it’s always drawn on top no matter what. Do GameObject → Create Other → GUI Texture. You can use layers with that.

–Eric

Eric,

Thanks for the help. I got it working now, but I couldn’t find a way to stretch my image to fit the screen rez of my game using script.

Is there something like the GUI matrix so my background image will be the correct size for any rez.

Also wasn’t GUI texture going to be obsolete later on?

If the scale is 0,0,0, then a GUITexture will use pixel values. Otherwise, you can set the scale to something else, and it will automatically scale without any scripting.

I sincerely hope not. They’re much too useful the way they are.

–Eric

I heard that as the new GUI scripting evolves and gets a graphical interface, GUITextures are going to deprecate and eventually vanish.