x


Unity Ignores the MainCamera Tag

I have two cameras, one for use with a RenderTexture and the other is the main camera.

The main camera is tagged "MainCamera" and the other is tagged "Untagged".

No matter what I do, unity uses the wrong camera to draw the scene.

I've tried

  • Creating the main camera first and then the other
  • Creating the other camera first and then the main
  • Reversing the tags!
  • Reversing their names!

Is there a way to tell Unity, OTHER than with tags, that I want to switch the active camera?

more ▼

asked Jan 14 '10 at 05:46 PM

Kevin Laity gravatar image

Kevin Laity
214 13 13 25

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

2 answers: sort voted first

Multiple cameras will each render what they see. However, unless you limit them to portions of the screen (called viewports) one will always render on top of the other. Which renders first and which last is determined by the depth, not by which one is tagged as the main camera.

To switch from one camera to the other, try setting enabled=false on one of them.

A simple example of rendering with two cameras to different parts of the screen can be found here.

To overlay two camera views (for example if one is generating the background) see the documentation on Camera.clearFlags.

more ▼

answered Jan 15 '10 at 03:10 AM

Bampf gravatar image

Bampf
5k 8 19 49

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

Any chance you by accident have two cameras tagged as MainCamera? happened to me once.

more ▼

answered Jan 14 '10 at 10:17 PM

Lucas Meijer 1 gravatar image

Lucas Meijer 1 ♦♦
8k 19 43 85

(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:

x3013
x325

asked: Jan 14 '10 at 05:46 PM

Seen: 1991 times

Last Updated: Jan 25 '10 at 12:47 PM