I'm trying to get all the json files from the StreamAssets folder on Android using this code
string filePath = Application.streamingAssetsPath; DirectoryInfo dir = new DirectoryInfo(filepath); FileInfo[] files = dir.GetFiles("*.json"); foreach (FileInfo file in files) { GameObject catalog = Instantiate(catPrefab) as GameObject; catalog.name=Path.GetFileNameWithoutExtension(file.Name).ToString(); Debug.Log(catalog.name); } On the Unity emulator, all files are loaded, everything works fine, but when I download the APK on Android, no file is found.
put a check on the existence of the file
DirectoryInfo dir = new DirectoryInfo(filepath); if (!dir.Exists) { Debug.Log("Нет такого каталога"); } How to make everything work on Android? thanks in advance
Debug.Log, so that you can visually analyze the cause yourself? put a try catch, too, as it should be, and pledge a problematic place - Alexey Shimansky