- Home /
NGUI Texture atlas help !
Hey I am new to NGUI and Texture atlases I created a texture atlas/ material/ prefab. But can someone gimme an example of how to draw a particular image from the atlas through scripting.
For example, If i Press R. I need to draw the Red box from the atlas
Comment
Answer by Lex_87 · Sep 19, 2014 at 02:49 PM
You can add game object to scene hierarchy, add NGUI Sprite Component to it. After that you can choose sprite from certain atlas and enjoy result already in scene view. After that you have to add some script that enables your sprite so:
private void Update () {
var sprite = GetComponent<UISprite> ();
if (Input.GetKey("R"))
sprite.visible = !sprite.visible;
}