i have editor script parsing textfile, the gamedesigner is changing the text file and i need to run one method to parse it every time he changes it, and it’s very uncomfortable to think about this particular thing every time
so is there any chance to hang some function to editor, which will be called everytime the refresh of assets occurs ?
1 Answer
1
You are trying to hook into the process when the text file gets re-imported right? Because the gamedesigner is changing the text file from outside of unity?
The first thing that comes to my mind is the AssetPostProcessor and the callback: OnPostprocessAllAssets. It gets called when any number of assets gets reimported, and then you either check if the textfile is one of them and then parse it, or parse it anyway just to be sure.
using UnityEngine;
using UnityEditor;
public class TextFileImporter : AssetPostprocessor
{
public static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
//Check if importedAssets contain a path to the textfile and then parse, or just parse the file every time this function is called.
}
}
Remember to put this in an Editor folder.
More on the function here: OnPostprocessAllAssets
thank you!
– komodordo you know any event that happens after compilation?
– andy_t