Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: bagomints on August 26, 2014, 03:14:01 PM

Title: Multiple cameras, UI is rendering in wrong camera
Post by: bagomints on August 26, 2014, 03:14:01 PM
Hey,

I have multiple panels that take care of different things, like 1 panel for scrolling combat text, another for character portraits, etc.

I'm using NGUITools.AddChild to instantiate and parent the UI elements to a container in the appropriate panel.

Like the scrolling combat text elements gets added to a container object in the scrolling combat panel.

They get added to the appropriate container object in the panel, but when I go to check the panel's camera, I see that they're not being rendered by that camera, they're using another camera.

But I have a 3rd panel that NGUITools.AddChild to a parent object in that panel, and they're actually rendered with that panel's camera.

So I'm confused why 1 panel is using its camera and another isn't.


EDIT: I found the issue :

NGUITools.FindCameraForLayer(gameObject.layer);

I used this code to get the camera that belongs to the UI element, and it's getting the first camera, which was the WRONG panel I needed.

A quick fix is just to change the layer of each UI element so they get rendered at the appropriate panels since each panel will have a camera for that layer only, etc.
Title: Re: Multiple cameras, UI is rendering in wrong camera
Post by: ArenMook on August 27, 2014, 04:21:10 AM
If you have multiple cameras, they should each have their own layer. You shouldn't have more than one camera being able to see the same layer.