Get path to a Sprite's texture

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By unchained

I was wondering, is there a way in GDscript to get the resource path of a Sprite’s texture? For example, let’s say I have a Sprite node called Hero, and calling this function on it would return “res://characters/hero.png”. I know there’s a way to set the texture, but I haven’t been able to find a way to get the path of an already set texture.

:bust_in_silhouette: Reply From: kidscancode

A texture is a Resource: Resource — Godot Engine (3.0) documentation in English

You can get a Resource path using resource_path:


You saved my life so many times… thank you.

TGMG | 2021-08-28 23:03