0 votes

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.

in Engine by (15 points)

1 Answer

+4 votes
Best answer

A texture is a Resource: http://docs.godotengine.org/en/3.0/classes/class_resource.html

You can get a Resource path using resource_path:

print($Sprite.texture.resource_path)
by (20,927 points)
selected by

You saved my life so many times... thank you.

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.