How can I display a flat background - 2D image, not a skybox - behind everything in my camera?

hi,

I am working on a characted editor and I want to separate the scene from the background. the editor has got different views and I need the same background in any of them. my idea was to simply add a flat 2D image to the game camera background (whatever Im using each time). I thought it would be much easier but I cant find out how to do it properly.

the closest Ive been is having a camera for the game scene and then create a 2nd camera whith a skybox in a separate layer but I cant set it up as non depth camera.

in any case, is there any way to simply add a flat image as background no mather which camera, view, perspective I have??

Thanks a lot!!

You're almost there, with the 2nd camera approach. Here's how to do it:

  • Create a new camera (GameObject -> Create Other -> Camera), and name it "Background Camera".

  • Create a new GUI Texture (GameObject -> Create Other -> GUI Texture), and name it "Background Image".

  • Click the "Layer" dropdown menu in the Background Image's inspector pane, and select "Add Layer".

  • In the next free "User Layer" slot, create a new layer name called "Background Image". This will be directly under the layer named "Terrain" if you haven't yet added any others.

  • Select your Background Image in the hierarchy, and give it the desired texture, and set the x, y, width and height under "Pixel Inset" so that it fills the screen appropriately.

  • Near the top of the inspector window, Use the layer dropdown menu to assign your "Background Image" layer that you defined earlier to this gameobject.

  • Now select your Background Camera in the hierarchy, and adjust these settings in the inspector:

    • Un-Check Flare Layer and Audio Listener (but leave GUILayer enabled)

    • Set Clear Flags to Solid Color

    • Set Depth to -1

    • Set Culling Mask, first to "Nothing", and then to "Background Image"

  • Now Select you other (main) camera, and in the inspector:

    • Set its Clear Flags to "Depth Only"

    • Click its culling mask setting, and un-check "Background Image". This should result in the culling mask displaying as "Mixed ..."

Voila, this should give you your GUI Texture rendered by your background camera, behind everything else rendered by your main camera. And for any other additional cameras (eg, other camera angles) that you want to use, just repeat the last two steps on them.

A very simple solution add a plane with background texture as child object to the camera so it will always keep the same position relative to the camera. Move the plane close to the 'far clipping plane' distance.

The old method does’t work quite well in Unity 5. To apply the same effect, you’ll need Sprite with your camera.

  • Create a new camera (GameObject > Camera), and name it “Background Camera”.

  • Create a new Sprite (GameObject → 2D Object → Sprite), and name it “Background Image”.

  • Click the “Layer” dropdown menu in the Background Image’s inspector pane, and select “Add Layer”.

In the next free “User Layer” slot, create a new layer name called “Background Image”.

Select your Background Image in the hierarchy, and give it the desired texture, and set the x, y, width and height under “Pixel Inset” so that it fills the screen appropriately.

Now select your Background Camera in the hierarchy, and adjust these settings in the inspector:

Un-Check Flare Layer and Audio Listener and GUILayer (Legacy in Unity 5)

  • Set Clear Flags to Solid Color

  • Set Depth to -1

  • Set Culling Mask, first to “Nothing”, and then to “Background Image”

Now Select you other (main) camera, and in the inspector:

  • Set its Clear Flags to “Depth Only”

  • Set Depth to 0

Click its culling mask setting, and un-check “Background Image”. This should result in the culling mask displaying as “Mixed …”

Things should be working now.

Sample code here: https://github.com/jamessa/ImageAsBackground

Best solution here (at least for me) :slight_smile: Adding and displaying a background — Pixelnest Studio