Read Files from a folder -> Load their icons as Textures

Hi,

Basic question: Why does access to some System.Drawing classes work from inside the Editor (via my own DLL file, which in turn calls System.Drawing), but not from a built standalone?

Detailed question: I am trying to create something like a filesystem inside Unity. For this, I load the Icons from files, apply them to Texture2D, and show that on some meshes.

To accomplish this, I need access to Icon and Bitmap classes (in System.Drawing). I do all this in an external DLL file. I KNOW that Unity "does not allow to access System.Drawing", but interestingly, it works perfectly fine from within the Editor. If I try to build this, it crashes on build and tells me that System.Drawing must not be included in the build. So I tried to cheat - I copied the System.Drawing.dll into the Plugins folder, and voila - the standalone gets built. But there are no textures, and the logfile shows a "TypeLoadingError" with the type "Gdip", when the

So the Icon class is working just fine, but the Bitmap class throws an error, but not in the editor.

Has, by chance, anyone got some similar problems (quite unlikely, I know) - and maybe even a solution?

I think the solution would be to [DllImport] the gdiplus.dll methods used by System.Drawing... but no luck so far.

Felix

Using TextAsset class would answer your question if you are trying just to load images stored as files. Here i am copying example from the TextAsset.bytes page of documentation:


```

// Load a .jpg or .png file by adding .bytes extensions to the file
// and dragging it on the imageTextAsset

var imageTextAsset : TextAsset;

function Start () { var tex = new Texture2D (4, 4); tex.LoadImage(imageTextAsset.bytes); renderer.material.mainTexture = tex; }

<hr>
from <a href="http://unity3d.com/support/documentation/ScriptReference/TextAsset-bytes.html" rel="nofollow">here</a>.</p>

<p>Hope this suits your requirement...</p>