Hi guys, i'm using Ngui but i need to get the Rect in screen coords of a Panel to send to another system.
I wrote this code below but it have limitations such it only works when using a Panel with center X=0,Y=0
There's a easier way to get it? I spend one day work to understand how NGUI works and make this code, looks like NGUI don't like too much give to us space screen coords, it's really sad for a GUI system.

function GetPanelRect()
{
var Root = GUIRoot.GetComponent(UIRoot); // The Root of the GUI
var UI_RootHeight = Root.manualHeight;
var UI_RootWidth = UI_RootHeight * (parseFloat(Screen.width)/Screen.height);
// Need to Keep Center X = 0 e Y = 0
var Panel = transform.GetComponent(UIPanel);
// Local Coordinates
var UI_PanelLocalwidth = (Panel.GetSides(transform)[2][0])*2;
var UI_PanelLocalheight = (Panel.GetSides(transform)[1][1])*2;
// Screen Coordinates
var UI_PanelScreenWidth = (UI_PanelLocalwidth*Screen.width)/ UI_RootWidth;
var UI_PanelScreenHeight = (UI_PanelLocalheight*Screen.height)/ UI_RootHeight;
var View = GameObject.Find("GUI_Cam").camera.WorldToScreenPoint(transform.position);
var FinalRect
= new Rect
(View
[0],View
[1],UI_PanelScreenWidth,UI_PanelScreenHeight
); return FinalRect;
}