foreach (Texture2D tex in photoTextures)
{
GameObject go
= new GameObject
("picture" + someIndex
); go.AddComponent("UITexture");
// this is where i try to assign the texture from the Resources folder. Everything after this line does not get executed.
go.GetComponent<UITexture>().mainTexture = tex;
...
}