+1 vote

Hi all,

I have this:

var currentTexture = get_node("TextureButton").get_normal_texture()

If I print that I get something like [ImageTexture:1500] or [ImageTexture:1363]
I'm looking to find something like truck.png or car.png for example.

I've looked at the docs for Texture etc but can't find anything related to this. Can it be done?

Thanks so much...

in Engine by (810 points)

1 Answer

+2 votes
Best answer

Use get_path(), it's defined in the Resource type (and Texture is derived from it). Resource documentation. The function returns the fully qualified path, that is, it includes res:// at the beginning.

by (52 points)
selected by

Thank you! I didn't consider looking higher up the resource tree (or whatever the correct term is) but it makes perfect sense now. Really appreciated. I now have not only the filename, but the path as well.

Thanks again!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.

Categories