- Home /
Background Bitmap
In the planning process for a game that has some hidden object 2D scenes, and something I thought would be quite easy is causing me some angst, putting a bitmap to the background of a scene.
I've thought about using a method described in this forum utilising a separate camera and layer for a gui texture of the background image. This however won't work, as the image won't resize on change of aspect ratio and I'm loath to restrict the games screen resolution as this annoys me when this is done on a game.
I thought there would have been a scripting option to replace the camera background colour with an image.
Anyway, if someone could point me in right direction it would be appreciated.
Thanks in advance. Rob F
Answer by Eric5h5 · Mar 23, 2010 at 06:23 PM
You don't need any scripting or anything...use a GUITexture for the background with a separate camera as you mentioned, and make sure the GUITexture has a scale of 1 on the X and Y axes, with 0 for all the pixel inset values. Since the scale uses viewport coords, 1 means it will always fill the screen regardless of resolution.
If you have Unity Pro, you can use the StaticBackground script on the wiki, which doesn't need multiple cameras.
Thanks Eric, great solution. The explanation about the viewport coords and xy scale was enlightening, thanks again.
Answer by x4000 · Mar 23, 2010 at 05:24 PM
You probably should look at SpriteManager (which is free), or SpriteManager 2 (which is paid). Those are the two most painless ways for rendering 2D images in Unity. There is also a 2D Shooter tutorial which does something along the lines of what you want, with a separate camera for the background only.
Answer by manuelr · Oct 25, 2010 at 12:17 AM
I have problems with de staticbackground.cs in unity 3 .How is possible?has Someone the same problem?
Your answer
Follow this Question
Related Questions
Background Image in a 2D game: problems of size/quality importing. What's the right workflow? 1 Answer
How can I unfocus and fade my background in a 2D game? 0 Answers
How would I go about constructing a layered scene? 2 Answers
Background not Crushed 1 Answer
2D Background texture flickering 0 Answers