GameObject labelObject = NGUITools.AddWidget(panelObject, UIWidgetType.Label); UILabel label = labelObject.GetComponent(); label.text = "Hello World!";
GameObject spriteObject = NGUITools.AddWidget(panelObject, UIWidgetType.Sprite); UISprite sprite = spriteObject.GetComponentThis code creates a new UISprite widget and adds it to a parent panel. The sprite's image is set to "my_sprite", and its size is set to 100x100 pixels. These examples use the NGUI library for Unity, which provides a set of tools for creating user interfaces.(); sprite.spriteName = "my_sprite"; sprite.width = 100; sprite.height = 100;