Convert String to object refrence

Hi,
so I have a “Set Sprite” and I want instead of using object refrence, use the name of the file which is a string . The name of sprie is exaactly like the sring but I don’t know how to connect these (also this is a android game and I have like 500 Sprite, so it can’t be a complicated method).
help if you know thank you

Ideally you’d set up a struct and use a data table. You can then easily organise data in an external spreadsheet and fetch a struct by name from the table directly. This would allow you to pack more data into the struct, in case you need to categorise it, for example.


Alternatively, you could try it like this, create an array first:

Image from Gyazo

And then populate the Map:

Untested but could work OK. But this will use asset name rather than custom name you might’ve defined. Not sure where the Example string comes from - looks like an asset name.

1 Like

Create a [Map][1]:

1 Like

Thank you it works, but the issue is that I have like 500 sprite, is there another way to do this?