taqin/src/Utils.gd

19 lines
525 B
GDScript3
Raw Normal View History

2020-06-10 17:15:33 +02:00
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