get resource file count in unity code example
Example 1: unity how to tell how many objets are in a folder
void Start()
{
string AssetsFolderPath = Application.dataPath;
string levelFolder = AssetsFolderPath + "/Resources/Levels";
Debug.Log("dataPath : " + levelFolder);
DirectoryInfo dir = new DirectoryInfo(levelFolder);
FileInfo[] info = dir.GetFiles("*.prefab");
int fileCount = info.Length;
Debug.Log("Level Count: " + fileCount);
Array.Clear(info, 0, info.Length);
}
Example 2: unity3d get all names of resources
using System.IO; using System.Collections.Generic; private List<string> PlayersInFolder; void Start () { PlayersInFolder = new List<string> (); string myPath = "Assets/Resources/"; DirectoryInfo dir = new DirectoryInfo (myPath); FileInfo[] info = dir.GetFiles ("*.*"); foreach (FileInfo f in info) { if (f.Extension == ".FBX" || f.Extension == ".prefab") { string tempName = f.Name; string extension = f.Extension; string strippedName = tempName.Replace (extension, ""); PlayersInFolder.Add (strippedName); } }