Adam's Lair Forum

game development and casual madness
It is currently 2019/10/17, 05:50

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: How to use Pixmap Atlas?
PostPosted: 2018/12/28, 23:12 
Newbie
Newbie

Joined: 2018/12/01, 06:01
Posts: 2
Role: Hobbyist
Hey guys, new to forum, been using Duality for prolly little more than a month. Usually any issues I come across I end up figuring out or luckily someone on here had the similar problem; However can't seem to find this one, and I do apologize if this was asked before and answered.
Pretty much I have a pixmap that I created an atlas on to access the separate imgs within the object but I can't seem to. I connect it with a contentref<pixmap> in a gameobject that holds UI icons, fonts, etc.. I've tried using the Material obj as well still not accessible. I appreciate any help you can lend and I apologize if this is easy and I'm just being stupid about it lol


Top
 Profile  
 
PostPosted: 2018/12/29, 14:13 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 2073
Location: Germany
Role: Professional
Hey there and welcome!

So you put multiple sprites on one image, and then want to use the Pixmap atlas to address them, correct? Here's a rough outline on how you can do that:

  1. Import the image as a Pixmap via dragdrop or import dialog. (You have done that already)
  2. Generate an atlas for the Pixmap, either by using its sprite sheet importer properties SpriteSheetColumns/Rows if it's a completely regular layout, or by right-clicking the Pixmap and choosing "Slice Pixmap" to bring up the atlas tool.
  3. Once you're done, you can verify the atlas to be correct using the preview in the inspector window top left, where you can select the previewed atlas index.
  4. Create a Texture from the Pixmap, if none exists yet. (You probably have done that already)
  5. Create a Material that uses the Texture, if none exists yet. (You probably have done that already)
  6. Create a SpriteRenderer object that uses the Material with your atlas'ed image. To display a specific atlas rect instead of the entire image, set the SpriteIndex property to the index you want to use.
  7. If, on the other hand, you want to use access the atlas rects from code, use methods from the Texture resource to retrieve the appropriate UV rect, as seen in this line.

Hope this helps ^^ Let us know if you need more info.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2018/12/29, 18:23 
Newbie
Newbie

Joined: 2018/12/01, 06:01
Posts: 2
Role: Hobbyist
Ah yes, this is what I needed. Thanks man, I appreciate it


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group