taqin/src/Utils.gd
Fabien Freling cd49ba8afc list all artworks from res://
I cannot simply explore the res:// filesystem on Android.
As a workaround, I create a static list of embedded artworks.
2020-06-19 17:03:46 +02:00

18 lines
525 B
GDScript

static func load_texture_from_path(path: String) -> Texture:
var img = Image.new()
var texture = ImageTexture.new()
if img.load(path) != OK:
print_debug("Cannot load image at path: ", path)
return null
texture.create_from_image(img)
return texture
static func deserialize_texture(path: String) -> Texture:
var file := File.new()
if file.open(path, File.READ) != OK:
return null
var img: Image = file.get_var(true)
file.close()
var img_tex = ImageTexture.new()
img_tex.create_from_image(img)
return img_tex