How to show RPG item icons from one atlas in a Godot 4 inventory
Short answer
Keep all icons in one atlas PNG and create an AtlasTexture per icon (atlas = the PNG, region = the icon's rectangle); assign it to a TextureRect or Button. A lookup function from item id to region keeps your inventory data-driven, and Nearest filtering keeps 32x32 icons crisp when scaled.
- Import the atlas with Filter Nearest.
- Create an AtlasTexture, set atlas to the PNG and region to Rect2(x, y, 32, 32).
- Assign it to a TextureRect in your slot scene; set Expand Mode and Stretch Mode Keep Aspect Centered.
- Store item id → region in a dictionary or a JSON file.
- Show rarity with material tiers or a coloured slot frame.
Copy-paste code
GDScript: an icon from an atlas region
var atlas := preload("res://icons/atlas.png")
func icon(col: int, row: int) -> AtlasTexture:
var t := AtlasTexture.new()
t.atlas = atlas
t.region = Rect2(col * 32, row * 32, 32, 32)
return t
$Slot/TextureRect.texture = icon(3, 0)Lootwren Icons: 393 RPG item icons for every loot tier
from $5Lootwren ships 393 32x32 icons with a ready LootwrenIcons.get_icon("ring_ruby") helper that returns the AtlasTexture, for $5.
Secure checkout · 14-day fix-or-refund if it doesn't work as described (terms)Questions
Why not one PNG per icon?
You can; an atlas means one texture to load and fewer files to manage.
Free: the Roblox Starter Kit
7 free Luau modules (damage, pets, shop formatting, admin audit log, tycoon guards and more) plus 3 free calculators, then 5 short emails with the scripting fixes we see go wrong most often.