Don't try to load the shader code if the file couldn't be opened

This commit is contained in:
ChaoticByte 2025-01-08 19:41:29 +01:00
parent 4d12ad4432
commit 7b72274140
No known key found for this signature in database

View file

@ -61,11 +61,12 @@ func save_result(path: String):
func load_shader(path: String): func load_shader(path: String):
print("Load ", path) print("Load ", path)
var file = FileAccess.open(path, FileAccess.READ) var file = FileAccess.open(path, FileAccess.READ)
self.shader_code = file.get_as_text() if file != null:
if "/" in path: # update current working directory self.shader_code = file.get_as_text()
self.cwd = path.substr(0, path.rfind("/")) if "/" in path: # update current working directory
self.last_shader_savepath = path self.cwd = path.substr(0, path.rfind("/"))
store_last_opened_file() self.last_shader_savepath = path
store_last_opened_file()
func save_shader(path: String): func save_shader(path: String):
print("Save ", path) print("Save ", path)