Resources.LoadAll Issue with variable type

private Texture2D pages;

// Doesn't work
string bookTitle = BookData.m_BookData[ID].GetTitle();
pages = (Texture2D)Resources.LoadAll("BookPages/" + bookTitle, typeof(Texture2D));

// Work, but can only load one at a time
string textureLocation = "BookPages/" + BookData.m_BookData[0].GetTitle() + "/1";
pages[0] = (Texture2D)Resources.Load(textureLocation, typeof(Texture2D));

I need to load all of the textures in a folder, each folder have different number of files.
But LoadAll will only load as GameObject.

Your LoadAll loads them all as an array - so you need to cast each element to Texture2D.

  var texture = (Texture2D)pages[0];

You could use Linq to get a Texture2D array and do it with:

  using System.Linq;

  var textures = Resources.LoadAll("Whatever", typeof(Texture2D)).Cast<Texture2D>().ToArray();