- Home /
Proper way to refresh asset
I'm having an issue when creating assets from text files. At some point, I need a set of assets to refer to other assets that I just created. However, this doesn't seem to be working, even when I save and refresh the AssetDatabase. The weird thing is that if I do asset creation and loading in two discrete steps, it seems to work, but if I try to do them as part of the same process, it no longer works (which is a big problem for my specific workflow).
Object prefab = PrefabUtility.CreateEmptyPrefab(assetPath);
PrefabUtility.ReplacePrefab(go, prefab, ReplacePrefabOptions.ConnectToPrefab);
Editor.DestroyImmediate(go);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
// evaluates to null
GameObject savedGo = (GameObject)AssetDatabase.LoadAssetAtPath(assetPath, typeof(GameObject));
How can I do this properly, so that I can immediately load an asset after creating it?
Your answer
Follow this Question
Related Questions
Proper way to update AssetDatabase after creating assets? 0 Answers
Creating a Mesh asset inside the editor 1 Answer
How do I wait until after AssetDatabase creates an assets before carrying out another function ? 0 Answers
Converting XML-files into assets 1 Answer
Get dynamic persistent asset reference 0 Answers