CRIWARE Unity Plugin Manual  Last Updated: 2024-07-12
[CriFs] Data installation (HTTPS)

Description of the sample

Overview

cri4u_samples_crifs_scene07_game_mini.png

This is a sample showing how to use CriFsWebInstaller to install data from a HTTPS server.

Operations

  • Start Install button
    Start the installation.

  • Stop button
    Stop ongoing installation or stop the CriFsWebinstaller which is in the Complete or Error state.

Scene information


Middleware FileMajik PRO (CRI File System)
Sample Basic samples
Location /CRIWARE/SDK/unity/samples/UnityProject/Assets/Scenes/crifilesystem/basic/
Scene file Scene_07_WebInstall.unity


Description of the program

void Start ()
{
// Initialize CriFsWebInstaller module
CriFsWebInstaller.InitializeModule(CriFsWebInstaller.defaultModuleConfig);
// Create CriFsWebInstaller
webInstaller = new CriFsWebInstaller();
}

Initialize the CriFsWebInstaller module and initiate an installer instance.
To control the behavior of the CriFsWebInstaller module, change the configuration passed to CriFsWebInstaller.InitializeModule.

void Update ()
{
CriFsWebInstaller.ExecuteMain();
}

Executes the periodic processing of the CriFsWebInstaller module every frame.

var statusInfo = webInstaller.GetStatusInfo();

Get the status, installation progress and other information of CriFsWebInstaller.
In the application, take appropriate action according to the state.

string destPath = System.IO.Path.Combine(CriWare.installTargetPath, destFileName);
if (System.IO.File.Exists(destPath)) {
System.IO.File.Delete(destPath);
}
// Start Install
webInstaller.Copy(this.url, destPath);

Start the installation.
Installed files are deleted in advance to avoid a "file already exists" error.

// Stop CriFsWebInstaller
webInstaller.Stop();

Stop the installation in progress or stop CriFsWebinstaller which is in the Complete or Error state.

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

Destroy the installer instance and finalize the CriFsWebInstaller module.