Duvyanshu
~matchmaker~
- Joined
- Feb 20, 2020
- Messages
- 26
- Programming Experience
- 1-3
Can somebody guide me in the right direction? My android game that I made on unity 2018.4.9 using C# on VS 2017 is unable to detect files at persistent data path.
The two font files are located in the persistent data path directory. This is a screenshot of app persistent data folder.
This is my code which locates the two font files.
Debugtext.text is a textbox which shows the result of three files: a) Font File 1 b) Font File 2 c) An Image File
The debug traces for files 1 and 2 are always false, whereas the image file returns true when it's present.
These fonts files are downloaded using UnityWebRequest from streaming path to persistent path using the following code:
The files are downloaded and written properly to the Persistent data path which is storage/emulated/0/Android/data/com.appname.com/files(cross-checked in traces.)
Why are these two font files not being located and returning false while other files in same path returns true?
Please, anyone, help me fix it. I gotta locate these two font files.
The two font files are located in the persistent data path directory. This is a screenshot of app persistent data folder.
This is my code which locates the two font files.
C#:
string fontpath1 = Application.streamingAssetsPath + "/LEOPALMHINDI15K710.TTF";
string fontpath2 = Application.streamingAssetsPath + "/LEOPALMHINDI14K240.TTF";
//Check Font 1 existence
if (File.Exists(fontpath1))
{
Debugtext.text += "true1\r\n";
}
else if (!File.Exists(fontpath1))
{
Debugtext.text += "false1\r\n";
}
//Check Font 2 existence
if (File.Exists(fontpath2))
{
Debugtext.text += "true2\r\n";
}
else if (!File.Exists(fontpath2))
{
Debugtext.text += "false2\r\n";
}
//Third File(Image file existence)
if (File.Exists(Application.persistentDataPath + "/FullShot.jpg"))
{
Debugtext.text += "trueIM\r\n";
}
else if (!File.Exists(Application.persistentDataPath + "/FullShot.jpg"))
{
Debugtext.text += "falseIM\r\n";
}
Debugtext.text += Application.persistentDataPath;
Debugtext.text is a textbox which shows the result of three files: a) Font File 1 b) Font File 2 c) An Image File
The debug traces for files 1 and 2 are always false, whereas the image file returns true when it's present.
These fonts files are downloaded using UnityWebRequest from streaming path to persistent path using the following code:
C#:
string fontpath1 = Application.streamingAssetsPath + "/LEOPALMHINDI15K710.TTF";
string fontpath2 = Application.streamingAssetsPath + "/LEOPALMHINDI14K240.TTF";
//Request Font1
UnityWebRequest request = UnityWebRequest.Get(fontpath1);
request.SendWebRequest();
while (!request.isDone)
{
}
System.IO.File.WriteAllBytes(Application.persistentDataPath + "/LEOPALMHINDI15K710.TTF", request.downloadHandler.data);
//Request Font2
UnityWebRequest font2 = UnityWebRequest.Get(fontpath2);
font2.SendWebRequest();
while (!font2.isDone)
{
}
System.IO.File.WriteAllBytes(Application.persistentDataPath + "/LEOPALMHINDI14K240.TTF", font2.downloadHandler.data);
The files are downloaded and written properly to the Persistent data path which is storage/emulated/0/Android/data/com.appname.com/files(cross-checked in traces.)
Why are these two font files not being located and returning false while other files in same path returns true?
Please, anyone, help me fix it. I gotta locate these two font files.