I’m loading an asset inside custom editorwindow script and nomatter what, it always on the first load returns null. I’ve tried to wait with update loop for it to load, I’ve tried recalling the load in update, no effect, only way is to get editor rebuild the assembly. Unfortunately i haven’t found a way to force the assembly rebuild.
Asset loading code:
public static bool GetAssetFile<T>(out T asset, string filter = "DefaultAsset l:noLabel t:noType") where T : ScriptableObject
{
bool found = false;
string[] guids = AssetDatabase.FindAssets(filter);
if(guids.Length > 0)
{
found = true;
string assetPath = AssetDatabase.GUIDToAssetPath(guids[0]); // only one loaded
asset = AssetDatabase.LoadAssetAtPath(assetPath, typeof(T)) as T;
}
else
asset = null;
return found;
}
If you have any insight how to refresh, reload the asset correctly or how to workaround this, I would appreciate it alot. Thank you verymuch beforehand.