Using a textureatlas, can you still reference the original names in code?

Godot Version

4.3

Question

I have created a TextureAtlas, and i notice when i drag the original files to my scene they’re now referencing the atlas.png that was created, which is great.

Is that the same in code? so a reference to res://Assets/somesprite.png would still use the atlas.png which contains somesprite.png when i make a script?

I think I’m facing the same need. I want to reference a region of an atlas as a ‘res://’.
I’m using gLoot in my game, and to define the item’s “protoset”, I could either separate the atlas in sprites and use res:// or find a “godot way” of specifying the region without extra code. or fiddle a bunch with the code.

I haven’t found a way. all uses of atlas imply some form of code to specify the region attribute.

I think you could create a new textureatlas with desired region and save it as resource, then reference this new resource in code.

1 Like

yes, that’s the solution I ended up going for yesterday. It’s a bit ‘noisy’ and I don’t really like it though :S

I tried modifying gLoot (great addon for loot and inventory system), but I’m not good enough in godot yet. I added the hability to specify a texture atlas path, a region, and a sprite size (default 16), and it works by itself but…
I had lots of issues with superclassing (can’t overload a class in godot hehe) and I have to read a bunch more.