0 votes

I've been trying the following for a very long time, with no success :(

I have an image saved in the C:\Users\My Name\AppData\Roaming\Godot\app_userdata\Calori folder (Calori is the name of my project) which I presume can be accessed by saying user:// using GDScript.

But after creating a variable called image_pathwith the path to this image in the user directory, I get the following error :(

E 0:00:03.975   _load: Resource file not found: user://image.jpg.
  <C++ Error>   Condition "!file_check->file_exists(p_path)" is true. Returned: RES()
  <C++ Source>  core/io/resource_loader.cpp:282 @ _load()
  <Stack Trace> objects.gd:7 @ _ready()

Any help would be greatly appreciated!

Godot version Godot Engine v3.2.1.stable.official
in Engine by (12 points)

1 Answer

+1 vote

load can only be used with imported resources, meaning the ones that are in the res:// folder. You will need to use Image.load():

var image = Image.new()
var image_texture = ImageTexture.new()

See here for all the details: https://docs.godotengine.org/en/stable/classes/class_imagetexture.html

The relevant part being:

This is because images have to be imported as StreamTexture first to be loaded with @GDScript.load.

by (1,433 points)
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 Frequently asked questions and 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 [email protected] with your username.