system
1
|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
Eidam |
Hello,
I need use variables as name of path to image.
Something like this, but this code isn’t working:
var map = 1
var img = "res://Graphics/Maps/" + str (map) + ".jpg"
$"Map".texture.resource_path = img
How I can do this?
Thnaks a lot for answers!
system
2
|
|
|
|
Reply From: |
felaugmar |
Call $"Map".texture = load(img)
instead of $"Map".texture.resource_path = img
changing the resource_path will not ‘reload’ the resource for you.
system
3
|
|
|
|
Reply From: |
Firty |
var map:int = 1
var img:String = "res://Graphics/Maps/"+str(map)+".jpg"
$Map.texture = preload(img)
preload
will not work if the path is not constant.
felaugmar | 2020-11-09 21:24