SmartlyDressedGames / Unturned-3.x-Community

Community portion of the Unturned-3.x repo. If you have access to the source code you can find it here:
https://github.com/SmartlyDressedGames/Unturned-3.x/
83 stars 17 forks source link

Add exception handler for Assets.onAssetsRefreshed #4421

Closed sunnamed434 closed 1 month ago

sunnamed434 commented 1 month ago

I've got an exception in onAssetsRefreshed (using my own client-side module) , I'd suggest adding a try-catch block in LoadAllAssets for that case when firing Assets.onAssetsRefreshed

As a result I've got an infinite load image

(Assets.LoadAllAssets)

this.CleanupMemory();
LoadingUI.SetLoadingText("Loading_Misc");
yield return null;
AssetsRefreshed assetsRefreshed = Assets.onAssetsRefreshed;
if (assetsRefreshed != null)
{
    assetsRefreshed(); // add try catch here
}
yield return null;
UnturnedLog.info(string.Format("Loading all assets took {0}s", Time.realtimeSinceStartupAsDouble - startTime));
Assets.isLoadingAllAssets = false;
yield break;
SDGNelson commented 1 month ago

Vanilla only uses this for the editor objects UI. Better here I think just to fix the exception in your code.