How do you keep unity from using an old version of an image file?

In my project I have a screenshot that the user takes. The problem is that unity won’t use the latest version of the image (as it is being written over many times). I got around this problem using AssetDatabase.Refresh from the UnityEditor package but now I realize that I can’t use that for real builds of this project (because UnityEditor can’t be used in anything other than the Unity Editor).

How can I get around this problem without resorting to the UnityEditor package?

Unity packs all assets during build time into an own file format and will not listen to any file changes after deployment.

You will have to load the texture from disk by your own and you cannot rely on unities assetdatabase update mechanism.

http://forum.unity3d.com/threads/read-image-from-disk.117866/

This one gives a good start how to utilize the class “WWW” and its “LoadImageIntoTexture” method to load a new texture after deployment. (Don’t get fooled by the name “WWW”. It reads from local files as well).

The links from rutter teach you how to listen on your file system if you want to immediately get informed when the file changes. (However, note that the file watcher may call its callbacks in an own thread, so you have to delay the actual reloading. E.g. by setting some bool variable which you check within Update()).