Kasuromi / GTFO-API

GNU General Public License v3.0
9 stars 7 forks source link

Async Bundle Loading and API to block base game's loading process #52

Open Flowaria opened 10 months ago

Flowaria commented 10 months ago

This PR allow GTFO-API to load bundles asynchronously and also adding loading screen to show players to what assets being loaded ATM

It would have some time-saving on loading multiple bundles even the unity's async asset loading is not fully working parallelly. (by saving little time loading file itself or listing assets)

Plus, this PR open new API in AssetAPI to plugin developers to load their stuff during loading screen asynchronously and print out process while loading

AssetAPI.OnCustomAssetsLoading += LoadAudios;

void LoadAudios()
{
  foreach (var file in files)
  {
    AssetAPI.WantToWorkForStartupAssets(out AssetLoadHandle loadingHandle);
    Task.Run(LoadAudioAsync(file, in loadingHandle));
  }
}

async Task LoadAudio(string file, in AssetLoadHandle loadingHandle)
{
  loadingHandle.AddLoadingText($"Start Loading Audio: {file}");
  //await Do Loading
  loadingHandle.AddLoadingText($"Loaded Audio: {file}");
  loadingHandle.SetCompleted();
}