Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: aidesigner on December 03, 2012, 09:55:36 AM

Title: UICamera on Main Camera and performance impact
Post by: aidesigner on December 03, 2012, 09:55:36 AM
From a performance standpoint it does not seem like a good idea to ever attach UICamera script to the main camera.   This would cause you to perform raycasts and call sendmessage constantly on every object in your scene with a collider.  The documentation gave me the impression you might do this if you required a persistent HUD.

1) Would a HUD be better achieved with the standard dedicated UI layer camera, with the prevision it is always enabled?

2)  If I have 1 or more GUIs that are actually part of my scene it would seem I have to use UICamera on MainCamera (Only Camera following player)?

3) Is the primary use case of NGUI on MainCamera to update GameObjects (ie. Player Scale) with events (ie. onHover), which is basically unrelated to GUIs?

4) Can you provide some practical suggestions of when to use UICamera on MainCamera and the performance consideration?

Thanks,
aidesigner
Title: Re: UICamera on Main Camera and performance impact
Post by: ArenMook on December 03, 2012, 11:20:59 AM
Will objects seen by the camera receive events? If yes, add a UICamera to that camera. If not, then don't.

The performance impact is pretty small -- just a single raycast, but no sense in adding it if you don't need it.

Yes, UICamera is only responsible for sending events, unrelated to GUI itself.