J
JamesG

Is there any loss of speed for loading portraits each time they're used?

Would it be faster, for example, to create a dictionary of loaded portraits at run time and load them by reference?

ie

portraits = {"happy": preload("happyface.png"), "sad": preload("sadface.png")}
func set_expression(expression: string):
    texture_rect.texture = portraits[expression]



1 love
  • Nathan Lovato replied

    Godot automatically caches every resource that you load. Under the hood, it keeps a dictionary of loaded resources for you. So in this case, adding an extra dictionary would not make a significant difference.