finding the texture filename of a texturebutton?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Robster
:warning: Old Version Published before Godot 3 was released.

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…

:bust_in_silhouette: Reply From: manokara

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.

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!

Robster | 2017-07-26 04:08