load all png files as resource but NOT from resource folder

I have an issue.
I need to be able to load all the *.png files at run time from a folder under steamingassets, these are dynamic images and can changed after build.
here is a sample of my code.

using UnityEngine;
using System.IO;
using System.Collections;

public class loadallimages : MonoBehaviour {

	// Use this for initialization
	void Start () {
        GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);
        string folderpath = Application.streamingAssetsPath + @"/Tiles/";
        // string[] FileList = Directory.GetFiles(folderpath, "*.png");//loads only png files
        Object[] textures = Resources.LoadAll(folderpath);
        int fred = Random.Range(0, textures.Length);
        Debug.Log(string.Format("fred is crurrently:{0}", fred));
        Debug.Log(textures.Length);
        Debug.Log(textures[fred].name);
        
        Texture2D texture = (textures[fred]) as Texture2D;
        go.GetComponent<Renderer>().material.mainTexture = texture;
	}
}

Resources.LoadAll wont load them at all (fred=0).

Resources.load wont load, I get a list of null objects :(.

code to load each file (note: you have to remove the “.png” from the file name to get the Resource.load to load them)(but it doesn’t)

string[] FileList = Directory.GetFiles(folderpath, "*.png");//loads only png files
        Object[] textures = new Object[FileList.Length];
        for (int ten =0; ten> FileList.Length;ten++)
        {
            textures[ten] = Resources.Load(FileList[ten].Substring(0,FileList.Length-4)); // removes the ".png" from the end of the file name
        }

I would like the ability to load all the tile images at start up form a streamingassets/tiles folder location to use them then discard them to free up memory.

I understand that placing them in the resources folder and then calling Resources.loadAll(“Tiles”) would load them however the files will be changed after release hence the need to use the steamingassets folder. if there is an option them please help
cheers
D2

Resources.Load is specifically for Resources, which is defined as “stuff in the resources folder when you build”

As far as I can tell, you’ll have to handle stuff in the streamingassets in a much more low-level manner. If you have -.pngs, you should read the bytes of the files (System.IO.ReadAllBytes), and use the Texture2D method LoadImage which converts a byte array into an image.

In general, if you’re going to be supplying arbitrary data to your application at runtime, you’ll have to write the code that handles parsing that data yourself.

I actually fixed my own issue with the code above

Change -->Texture2D texture = new Texture2D(32,32); to
–>Texture2D tex = new Texture2D(x, y, TextureFormat.DXT5, false);

The TextureFormat is the key here as this sets the texture to a compressed texture;
see link text for details. this then freed up some more memory for the processing