- Home /
Refresh File Resource Folder or File
Hi
I have been stuck on this for hours, any help would be appreciated.
I have downloaded a file to the file resource folder.
When trying to access it, it doesn't see it unless I tab out of focus from unity editor and tab back.
How can I refresh the resource folder or file in it?
Answer by Glurth · Dec 15, 2017 at 09:50 PM
The menu item "Assets->Reimport All" will rebuild Unity's database of folders and files in the Asset folder (and it's sub-folders) of the project.
If your project has many files and folders this might take a while. Note that this will also recompile all scripts and run the import procedure on textures and models.
I suspect, but have not tested, that you can select the folder that holds these externally added sub-folders, and select asset->Reimport or right-click->reimport (as opposed to "reimport all"), to minimize the time it takes.
I need to refresh via code since when building the app for mac or android I can't do the Reimport all since that is the unity editor function and needs to be build into app automatically.
Same problem. Have you found any answer? If so, share please :)
I just ended up storing everything in player pref variables. Not ideal, but does the job.
AssetDatabases seems like the best way to do this though. I didn't have the time to figure it out but that way would be ideal.
Answer by GuruJeya14 · Jun 11, 2019 at 09:44 AM
Load your file again using the local-downloaded-filepath
//Acts as a refresh coroutine - Async
public IEnumerator LoadDownloadedFile(string downloadedFilePath)
{
WWW loadFile = new WWW("file:///" + downloadedFilePath);
yield return loadFile;
if (loadFile.isDone)
{
//Do the needfull
//You can now access the file from anywhere else
}
}
Your answer
Follow this Question
Related Questions
How do I read unicode text file on IOS from resources folder? 1 Answer
How to read text file from resources and store into 2d array 3 Answers
How to load a large text asset with minimum to no lag. 2 Answers
Updating txt from an url (webplayer) 0 Answers
[TextMeshPro] Generate Font Atlas failed, error code 8, how can I fix it ? 1 Answer