I’ve stumbled across the following problem and was hoping anyone could help me out.
In my project, I have implemented a postprocessor class. The postprocessor configuration is defined in a class derived from ScriptableObject and is stored in settings.asset.
So, when the postprocessor encounters an asset which needs processing, it loads the settings.asset and figures out what should be done.
However, when I check out this project (SVN) and open it for the first time, the settings.asset file is imported after the files that need processing and cannot be used.
I have already tried using:
private void OnPreprocessModel()
settings = (Settings)AssetDatabase.LoadAssetAtPath(settingsPath, typeof(Settings));
But unfortunately this does not work.
Does anyone know how I could get this to work without having to resort to a different type of configuration file (e.g. xml)
Any help would be appreciated.
So even though this question was asked long ago I hit the same problem and had to faff around to get something that worked so here goes The Internet.
I can’t see a way to override the unity import order so what I did instead is detect when my “config file” asset was imported and use that moment to kick off reimporting my model asset. Did so like this:
static void OnPostprocessAllAssets (string importedAssets, string deletedAssets, string movedAssets, string movedFromAssetPaths)
foreach (var str in importedAssets)
Match match = Regex.Match( str, "(^.*?).asset$" );
if( match.Success )
AssetDatabase.ImportAsset( match.Groups[ 1 ].Value + ".fbx", ImportAssetOptions.ForceUpdate );
So what happens in a reimport all\initial checkout is the following:
1)model gets imported, can’t find the config file
2)config gets imported
3)model file gets imported again and now the config file exists
Obviously this is not the most efficient thing in the world but it does have the virtue of working. If anyone else has a better way of doing this I’d be interested to hear.
An option that is not blatantly obvious would be to use a ScriptableSingleton class. The advantage of this class is the fact that you tell it when to load. They are ScritpableObjects that can save outside of the Unity project.
The only sad thing is that you can’t use this class out of the box since one of the attributes it uses is internal but you can recreate all the functionality by using