Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: aholla on May 23, 2014, 09:50:56 AM

Title: Get the current Camera
Post by: aholla on May 23, 2014, 09:50:56 AM
Hi, I would like to get the current camera so I can tween a panel in from outside the camera view/bounds.

I have tried various methods: UICamera.current return null, NGUITools.FindInParents<UICamera>( gameObject ) returns null.

To make things a little more confusing I have two UIRoots and therefore two UICamera.

UIRoot1
- UIPanel
- UICamera

UIRoot2
-UIPanel
-UICamera

SO just to reiterate what I am doing. In code I am trying to tween an existing object in the hierarchy. I want to position it outside the view of the camera and tween/slide it in.

Any suggestions?

Also related to my issues I have managed to get my panel to appear offscreen with the following code:

  1. int paneloffset = Mathf.FloorToInt( UIRoot.GetPixelSizeAdjustment( gameObject ) * ( Screen.width / 2f ) ) + 1;
  2. paneloffset += 480;
  3. gameObject.transform.localPosition = new Vector3( -paneloffset, 0, 0 );
  4.  

My Panels have been designed to be 960px wide so I am adding 480 pixels to the offset. Is this okay or will I run into problems with this approach?


Thanks
Title: Re: Get the current Camera
Post by: ArenMook on May 23, 2014, 04:40:37 PM
Assuming your UIRoot is set to pixel perfect, yes -- it's a fine approach. Otherwise you need to take UIRoot's pixelSizeAdjustment into consideration.