x


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

more ▼

asked Mar 23 '10 at 01:43 PM

RobF gravatar image

RobF
70 2 2 8

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

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.

more ▼

answered Mar 23 '10 at 06:23 PM

Eric5h5 gravatar image

Eric5h5
81.5k 42 133 529

Thanks Eric, great solution. The explanation about the viewport coords and xy scale was enlightening, thanks again.

Mar 23 '10 at 10:18 PM RobF
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Mar 23 '10 at 05:24 PM

x4000 gravatar image

x4000
504 23 25 40

I'll look a these thanks

Mar 23 '10 at 10:22 PM RobF
(comments are locked)
10|3000 characters needed characters left

I have problems with de staticbackground.cs in unity 3 .How is possible?has Someone the same problem?

more ▼

answered Oct 25 '10 at 12:17 AM

manuelr gravatar image

manuelr
1

Not an answer - use a comment.

Dec 14 '10 at 01:05 PM Herman Tulleken
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1071
x505
x172

asked: Mar 23 '10 at 01:43 PM

Seen: 3682 times

Last Updated: Mar 23 '10 at 01:43 PM