I came across an issue today on something I thought would be very straightforward.
I’m looking into loading a bunch of PNG files whose names are stored in a XML doument. These files can be either stored in an external folder or loaded in Unity’s asset directory beforehand.
I simply want to use these files as textures to create buttons for a GUI interface. My script already loads the content of the XML file and creates the buttons for the GUI. I just need to bridge the gap now
I had a look at the dedicated page Unity - Manual: IMGUI Basics but I couldn’t find any relevant help. Nothing more on the forums unfortunately.
Can anyone help me with that? I doubt it’s a major issue to solve but honestly, I’m lost!
// "Empty" texture. Will be replaced by LoadImage
Texture2D texture = new Texture2D(4,4);
FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
byte[] imageData = new byte[fs.Length];
fs.Read(imageData, 0, (int) fs.Length);
texture.LoadImage(imageData);
If using JavaScript, you can find good starting point in docs: