CRIWARE Unity Plugin Manual  Last Updated: 2024-07-12
[CriFs] Loading a CPK file (packed file)

Description of the sample

Overview

cri4u_samples_crifs_scene02_game_mini.png

Loads files from a CPK file (FileMajik PRO's dedicated packed file).

Operations

Step 1: select the source CPK file and bind it.
Step 2: load the specified file from the bound CPK file.
  • Step1 Bind CPK File
    • Bind CPK File (Local) button
      Binds a local CPK file.

  • Step2 Load File
    • Load Image File button
      Loads and displays an image file from the bound CPK file.

    • Load Text File button
      Loads and displays a text file from the bound CPK file.

  • Reset button
    Resets the settings.

Scene information


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


Description of the program

this.binder = new CriFsBinder();

Create a file system binder.

CriFsBindRequest request = CriFsUtility.BindCpk(this.binder, path);

Request binding of the CPK file.
Binding is executed asynchronously in the background.

yield return request.WaitForDone(this);
if (request.error == null) {
this.bindId = request.bindId;
}

Wait until binding is complete.
If binding completed successfully, a bind ID can be obtained from the request.

var request = CriFsUtility.LoadFile(this.binder, path);

Request the loading of the file in the binder.

CriFsBinder.Unbind(this.bindId);

Cancel the binding.

this.binder.Dispose();

Dispose of the binder.
Note that resources are leaked if the binder is not destroyed.