Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: shrikky on February 06, 2014, 06:24:55 AM

Title: Texture Atlas help
Post by: shrikky on February 06, 2014, 06:24:55 AM
Hey, I am new to NGUI / Texture atlas .

I've created a texture atlas using the tutorial vids, but I don't know how to access a particular sprite from the Atlas using script. Can someone help me with this?
Example : I have an atlas named _Xatlas with 10 sprites in it. If I want to draw the sprite named "RED" if i press A, how do i do it using script?


Thanks
Title: Re: Texture Atlas help
Post by: ArenMook on February 06, 2014, 09:14:04 PM
  1. UISprite sprite = GetComponent<UISprite>();
  2. sprite.spriteName = "RED";
Title: Re: Texture Atlas help
Post by: shrikky on February 07, 2014, 12:00:40 AM
Thanks a lot Aren, I was literally waiting for your reply and now I am able to swap images on inputs from the same atlas  :)

Is there any tutorial which covers the scripting part using NGUI? I can see a scripting reference on NGUI but I feel that it would be easier for beginners to see an example code along with it like how it is in Unity Scripting reference. Also do let me know if you have explained with scripting in any of your youtube videos.

It would be great if you can give me some input for sprite animation as well.
Title: Re: Texture Atlas help
Post by: ArenMook on February 08, 2014, 02:05:04 PM
For a very basic example of sprite animation via code, look at UISpriteAnimation component. It has some pretty simple code inside that you are welcome to make a copy of and modify to suit your needs.