1. Well. There are several ways to archieve this.
1.1 The best thing would be to use Unity as a graphicial interface and a code generator exports the designed user interface.
Well. I like Windows Forms. I would kill for such a user interface in Unity.
1.2 In the current version i would suggest something like the following. The parent and root are just assigned in the Start method. On Instantiate it will be assigned automatically and on Parenting you can assign it by code.
public class NGUIComponent : MonoBehaviour {
private NGUIComponent root;
private NGUIComponent parent;
// Use this for initialization
void Start () {
parent = Find(transform.parent);
root = Find (transform.root);
Debug.Log (string.Format ("[NGUIComponent, Source: {0}, Parent: {1}, Root: {2}] ", transform, parent, root));
}
private NGUIComponent Find (Transform source) {
if (null == source) {
return null;
}
return source.GetComponent<NGUIComponent> ();
}
public void OnDestroy () {
parent = null;
root = null;
}
}
The NGUIComponent contains the calculated Bounds as well. I would say to ensure theres no much invocation, i suggest to process any NGUIComponent in one Update method.
Any component is registered to this NGUIManager itsself and is processed in one Update. Even the Tweens, moves etc. Anything else should be handled by delegates or interfaces.
public class GuiManager {
public void Update () {
NGUIManager.Instance.Update();
}
}
This approach is like the Java Component Model. Component is anything. Panel is a collection of components. Windows is a collection of panels.
But well. I cant ensure anything for this. I just know theres no need to call GetComponent so often. It really kills this great framework.
2. The Statics?
I found the following code in nearly any NGUI file. I replaced it with <T> to visualize that any class has it. Because of the massive code duplication, i think its a surrounding for something.
Well statics are not bad. Yesssssch.

static public T current;
current = this;
.
.
.
current = null;
3. Well. I think theres no need for a static class like EventDelegate. In most cases statics are a lazy way to solve problems. Separate Events for each NGUI Tool would be an approvement as well.
Unity and UI is since version 1.0 a mess and i have respect for any improvement and ui developing. This framework is really an improvement but it has edges need to be rounded.
