taqin/src/Utils.gd

19 lines
529 B
GDScript3
Raw Permalink Normal View History

2024-09-02 13:13:14 +02:00
static func load_texture_from_path(path: String) -> Texture2D:
2020-06-10 17:15:33 +02:00
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
2024-09-02 13:13:14 +02:00
static func deserialize_texture(path: String) -> Texture2D:
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