// Define event identifier public const string SOMETHING_EVENT = "OnSomethingHappened"; // Define event handler delegate public delegate void SomethingEventHandler(); // Register listener method void Start() { NGUITools.Register(gameObject, SOMETHING_EVENT, HandleSomething); } // Handle event void HandleSomething() { Debug.Log("Something happened!"); } // Broadcast event void DoSomething() { NGUITools.Broadcast(gameObject, SOMETHING_EVENT); }
// Register listener method void Start() { UIEventListener.Get(button.gameObject).onClick += HandleButtonClick; } // Handle event void HandleButtonClick(GameObject go) { Debug.Log("Button clicked!"); } // Broadcast event void DoButtonClick() { UIEventListener.Get(button.gameObject).onClick(); }Package Library: NGUI is a commercial package library developed by Tasharen Entertainment. It provides a robust UI system for Unity3D with features such as sprite-based graphics, dynamic font rendering, and localization support. The NGUITools Broadcast method is part of this package and can be accessed through the NGUI namespace.