0 votes

I'd like to allow a player to load a custom texture from their local storage.
I'd also need to know the dimensions of the file so I can map it to assure proper aspect ratio.

in Engine by (199 points)
retagged by

1 Answer

+2 votes

You can if you get access to the path to that file, but I'm not sure that getting the path will work the same on platforms where filesystem access is restricted.

Once you get the file, you can do something like this:

var im = Image.new()
var err = im.load(path)
if err != OK:
    print("Could not load image file")

var tex = ImageTexture.new()
tex.create_from_image(im, Texture.FLAGS_DEFAULT)
by (27,956 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 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.