To create a button in NGUI looks like we need to create something called Atlas that is a material that contains a lot of little images called Sprites.

I created a set of 40 sprites (for 20 buttons needed in game, normal state and clicked state) in photoshop in a 2048x2048 image file. When i tried to use NGUI atlas maker i realized that atlas maker requires each sprite in a separate file and wants to merge them in the atlas itself!

Well, i already have them in one file, should i slice all these buttons and save them in 40 other separate files and let the atlas maker merge them again for me? (Sounds very stupid!)

Isn't there any way to give the merged 2048x2048 file to atlas maker (or any other equivalent plugin/software) and then tell the software "Hey! I have 40 sprites in this image, let me tell you where they are! The first one is in (3,3) with size of (150px, 150px), The second one is..."?

UPDATE: I found a part of solution, unity could identify my 40 sprites in texture using sprite editor tool, but NGUI cannot still find them.

I created a material using "Unlit/Transparent Colored" shader and referencing the atlas to it, then i created a new empty game object, added UI Atlas component to it and referenced the material in it, but it says there are no sprites. If i make a prefab out of this game object then NGUI can use it as an atlas and my problem will be solved

  • 1
    \$\begingroup\$ I think the advantage of letting your atlas maker do its job is to have it generate the items coordinate, instead of having you do it. \$\endgroup\$ – Vaillancourt Jun 6 '15 at 15:27
  • \$\begingroup\$ @AlexandreVaillancourt I already have setup guid lines in photoshop and that won't be a problem \$\endgroup\$ – Mohammad Jafar Mashhadi Jun 6 '15 at 15:36
  • 1
    \$\begingroup\$ I guess it's much less practical to make the atlas yourself that they didn't think anyone would bother doing it. \$\endgroup\$ – zoran404 Jun 6 '15 at 23:26
  • 1
    \$\begingroup\$ Since you mentioned you are using Photoshop, here is a Photoshop script that does what you want, however the output file might not be entirely compatible with Unity. However you can tweak it to fit your needs. Disclaimer, I’m the developer of the script. \$\endgroup\$ – rraallvv Jan 17 '17 at 3:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.