CRIWARE Unity Plugin Manual  Last Updated: 2024-07-12
[CriFs] Data batch installing

Description of the sample

Overview

cri4u_samples_crifs_adv01_game_mini.png

This is a batch installation sample using the BatchWebInstaller script where data are installed in bulk.
BatchWebInstaller is implemented using CriFsWebInstaller.
BatchWebInstaller behaves in the following manner.
  • Parallel installation is possible.
  • It transitions to ErrorOccured state when one of the installations fails, and then transitions to the ErrorStopped state when the other ongoing installation is complete.
  • Calling BatchWebInstaller.Stop will put installations that are unfinished or failed back to the queue.
    • You can restart the batch installation by calling BatchWebInstaller.Stop, waiting for the Stop state, and then calling BatchWebInstaller.Start.

Operations

  • [Initialize Install Queue]
    Clear the installation queue in BatchWebInstaller and add new installation jobs to it.
    Installed files will be deleted.

  • [Start or Resume Batch Install] Button
    Start or resume the batch installation.

  • [Stop] Button
    Stop ongoing installations.

Scene information


Middleware FileMajik PRO (CRI File System)
Sample Advanced samples
Location /CRIWARE/SDK/unity/samples/UnityProject/Assets/Scenes/crifilesystem/advanced/
Scene file Scene_01_BatchWebInstall.unity


Description of the program

void Start ()
{
// Initialize CriFsWebInstaller module
var config = CriFsWebInstaller.defaultModuleConfig;
config.numInstallers = installConcurrency;
CriFsWebInstaller.InitializeModule(config);
// Create BatchWebInstaller
batchWebInstaller = new BatchWebInstaller(installConcurrency);
InitializeInstallQueue();
}

Initialize the CriFsWebInstaller module and initiate BatchWebInstaller.
To control the behavior of the CriFsWebInstaller module, change the configuration passed to CriFsWebInstaller.InitializeModule.
Also, new installations are added to the queue here.

private IEnumerator StartBatchWebInstall()
{
batchWebInstaller.Start();
while (true) {
// CriFsWebInstaller.ExecuteMain is executed in the BatchWebInstaller.Update
batchWebInstaller.Update();
if ((batchWebInstaller.status == BatchWebInstaller.Status.Complete) || (batchWebInstaller.status == BatchWebInstaller.Status.ErrorStopped)) {
break;
}
yield return true;
}
}

This is a coroutine that executes periodic processing of the BatchWebInstaller module every frame and waits for the completion of the batch installation.
CriFsWebInstaller.ExecuteMain is called within BatchWebInstaller.Update hence does not need to be called explicitly.

void OnDestroy()
{
// Destroy BatchWebInstaller
batchWebInstaller.Dispose();
batchWebInstaller = null;
// Finalize CriFsWebInstaller module
CriFsWebInstaller.FinalizeModule();
}

Destroy BatchWebInstaller and finalize the CriFsWebInstaller module.