Unity GUI Texture with file path


I am creating a level selection screen. Every level will has it’s own picture in the selection screen. Usually, to draw a texture to the GUI, we need to create a variable to store it. However at 70 levels, that would be rather complicated.

So, is it posibble to draw a texure to the GUI by using it’s file path, rather than a variable? That way I can store the paths in an array, and my job would be much easier.

So, is it possible, and if it is, than how?



you could use Resources.Load(<leveltexture + i>, Texture2D), this function loads a texture asset from Assets\Resources directory, which can be used by your GUI code.