detect when a textasset has changed

I am sure it’s documented or been asked already, but I just can’t find the right set of keyword to find the answer…

basically, I have a testAsset, an xml file, that I parse with a script. the scripts now runs in edit Mode.

I’d like to detect automatically that the xml file has changed and re parse it, instead of have to have a custom inspector with a button to trigger the parsing.

basically, how can I be notified in my script ( or in the custom inspector script), that an sset has changed?

thanks in advance.

Jean

I know that I’m kind of doing some Necromancy here, but I was looking for the solution to this problem and thought it would be nice to document the solution that I found here for any further searchers.

From the documentation at [AssetPostprocessor.OnPostprocessAllAssets][1] I have my C# script:

public class DetectChanges : AssetPostprocessor  
{
	
	static void OnPostprocessAllAssets (
        string[] importedAssets,
        string[] deletedAssets,
        string[] movedAssets,
        string[] movedFromAssetPaths) 
	{    		
		foreach (string str in importedAssets)
		{
            Debug.Log("Reimported Asset: " + str);
			string[] splitStr = str.Split('/', '.');
			
			string folder = splitStr[splitStr.Length-3];
			string fileName = splitStr[splitStr.Length-2];
			string extension = splitStr[splitStr.Length-1];
			Debug.Log("File name: " + fileName);
			Debug.Log("File type: " + extension);    			
		}
		
        foreach (string str in deletedAssets)
            Debug.Log("Deleted Asset: " + str);

        for (int i=0;i<movedAssets.Length;i++)
            Debug.Log("Moved Asset: " + movedAssets _+ " from: " + movedFromAssetPaths*);		*_

* }*
}
This helped my issue where I needed to know the Folder, filename, and the file extension of every file that is changed. Keep in mind that in order to use AssetPostprocessor you must include: using UnityEditor;
_*[1]: http://docs.unity3d.com/Documentation/ScriptReference/AssetPostprocessor.OnPostprocessAllAssets.html*_

FileSystemWatcher should work well if latency is acceptable,FileSystemWatcher should work if latency is acceptable