- Home /
Proper way to update AssetDatabase after creating assets?
I am attempting to use 2 text files to create a bunch of assets, and am doing so successfully except for one major problem. Here is the gist of what I'm doing.
public static void OnPostprocessAllAssets (...)
{
if (textFilesHaveChanged)
{
CreateAssetsFromFile1();
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
CreateAssetsFromFile2(); // throws errors when assets created from file 1 are loaded
}
}
The issue is that the assets I create in the first function call are not available when I am creating the second batch of assets. However, if I comment out the first function call, leaving the files that were created the last time the script was run, the second batch of files is able to find them with no issues.
How can I ensure that this works properly? It doesn't seem as though the AssetDatabase is actually being refreshed when I call Refresh().
Your answer
Follow this Question
Related Questions
Proper way to refresh asset 0 Answers
Creating a Mesh asset inside the editor 1 Answer
Seperating editor and runtime data with ScriptableObjects 1 Answer
Detecting Asset Types 3 Answers
AssetDatabase.CreateFolder question 1 Answer