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
|
|
|
|
|
2020-06-17 19:11:20 +02:00
|
|
|
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
|