|
Hi all, I have followed the instructions here to create a background image in a second camera. The main camera is set to ignore the background layer (culling mask has everything except background), and the background camera is set to only see the background image (only background is set in culling mask). My code instantiates many game objects dynamically. These are not visible in my scene - it looks like they are behind my GUITexture because when I click run in the editor I can see them in the scene window, just not in the game window. Any ideas?
(comments are locked)
|
|
I have done some more testing, and this seems to be an editor quirk/bug. For example, quitting and restarting Unity resolves this issue - until I change the scene view (e.g. zoom in/out), after which it stops working again. Making an unrelated code change in a script then fixed it again. And so on... I am using Unity Free (2.6) on Windows Vista. Sounds like maybe you haven't set the camera depths properly. Having two cameras with the exact same depth results in random behavior like that, since there's no deterministic way to tell what camera will render on top.
Aug 08 '10 at 11:01 PM
Eric5h5
The cameras have different depths and are in different locations. Should I set the background camera to have the shortest depth?
Aug 09 '10 at 07:53 AM
pixelthis
The background camera should have the lowest depth, so set it at depth of -500 just to be sure you're not getting confused (yes, that's a minus sign).
Aug 09 '10 at 02:11 PM
Cyb3rManiak
(comments are locked)
|
|
In the mean while, if you want to try another way while you're designing the game - try creating this C# script (CreateBGPlaneOnCamera.cs) and attaching this to your BG camera. Set nBackgroundLayerID to the BG layer number, and assign a texture to txBackground. It should get ya there quick and dirty. When you're ready to stop playing around, just return to using the GUILayer approach, since I don't think that quirk/bug will happen in a built player.
(comments are locked)
|
|
you should put your new objects into its layer. like this: I don't think that is the problem. Does Instantiating a game object place it on my user-defined background layer by default?
Aug 08 '10 at 08:32 PM
pixelthis
Thanks for your help AliAzin - in the end it turns out it is probably editor related.
Aug 08 '10 at 10:44 PM
pixelthis
(comments are locked)
|
