Refresh file on android (and ios)

Hi!

At startup Unity loads some text files in Resources folder.
Later I delete some files but I also create new ones with the same names (and paths) but with changed data.

I use Resources.Load to load my TextAssets.

To make Unity aware of the change in Editor I have to call AssetDatabase.Refresh() which works fine in the editor (small lagg), but is not accessible on Android / iOS.

How can I “refresh” the system to make it aware the changed files on android? (and iOS).

Pretty sure you shouldn’t be changing files in Resource on Android and iOS. Add the files to your persistantDataPath and make changes there.

Anything in the UnityEditor namespace, including the AssetDatabase class, will NOT be in the final build. Those are editor-only utilities. Not only that, but EVERYTHING in the final build is immutable: you cannot change it at runtime when you are not in the editor.

You may want to load the files from the project using Resources.Load(), then write them off to files in Application.persistentDataPath, where you can modify them as much as you want.

Once they are in that area they are just files on the operating system “disk,” and hence they don’t need to be refreshed. Refreshing is a concept that exists (for Unity) only in the editor at editing time.

Thank you all, using the persistantDataPath worked!

1 Like