Search Unity

The ScriptableObject load from LoadAssetAtPath is unload after invoke AssetDatabase.Refresh

Discussion in 'Asset Database' started by watsonsong, Oct 30, 2019.

  1. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    555
    I loaded an ScriptableObject by using AssetDatabase.LoadAssetAtPath and do some work in batch mode. But after some AssetDatabase.Refresh, the ScriptableObject is null.

    I find the AssetDatabase.Refresh will automaticly trigger the Resources.UnloadUnusedAssets from document. And the Resources.UnloadUnusedAssets will not check the variable on call stack.

    So is it a best practice if I invoke any AssetDatabase.Refresh inside a ScriptableObject method, I need mark it dirty?
     
    Last edited: Oct 30, 2019