Adding the Kii Cloud SDK

The Kii Cloud SDK gives you the ability to manage application users and data with just a few lines of client-side code.

Configuring your project

Follow the steps below to add the Kii Cloud SDK to your Unity application's project:

  1. Launch Unity and double click on the KiiCloudUnitySDK.unitypackage.

  2. Select and import all files in the list.

  3. Select Edit -> Project Settings -> Player to open the Player Settings and set the Internet access as required in the "Setting for Android" tab.

  4. Create an empty Game Object and bind it to the KiiInitializeBehaviour.

    First, Create an empty game object.

    Next, drag & drop the KiiInitializeBehaviour onto the empty game object just created. You can find the KiiInitializeBehaviour by clicking the triangle icon beside the KiiCloudUnitySDK.dll.

    Finally, rename the game object to something you will remember (like KiiInitializer).

    You can drag & drop the game object to change its hierarchy, but please make sure to bind the KiiInitializer to the game object that locates at the root level. If you bind it at the lower hierarchy, the initialized information could be lost when the scene changes.

  5. Set the AppID, AppKey and Site in the game object's property. Make sure to set the value that corresponds to the site location you've specified on the developer portal (Kii.Site.JP, Kii.Site.US, Kii.Site.CN3, Kii.Site.SG, or Kii.Site.EU).

    You basically do not have to directly set "Server Uri" property (e.g. setting Kii.Site.US on the Site property is equivalent to setting in the Server Uri property).

    You can also specify the timeout (sec) for the SDK to access Kii Cloud.

Note: When you are updating the SDK, you need to delete all the DLL files first and then copy new ones.
This operation will clear all settings you've made on the KiiInitializeBehaviour (e.g. AppID and AppKey), so please re-configure the KiiInitializeBehaviour by setting these values again.

You can safely embed the AppID and AppKey in your application as long as you apply the correct access control. See Security for more information.

Setting the compiler flag

If you are building your application for iOS with Unity 5 or later, you need to set the compile option with the steps below. Otherwise, you will get an error when you try to compile on Xcode.

  1. Click "" on the Unity 5 Assets/Plugins/iOS.

  2. Set "-fno-objc-arc" as "Compile Flags" in Inspector section.

  3. Click "Apply" in Inspector section.

Changing the timing of the SDK initialization

The class KiiInitializeBehaviour is inheriting the MonoBehaviour, and it initializes the SDK in the Awake method. You will get the InvalidOperationException if you execute the Kii Cloud SDK API before this initialization.

If you are calling the Kii Cloud SDK API in the MonoBehaviour.Awake that is bound to another game object, you will need to configure the script execution order so as to load the KiiInitializeBehaviour before other scripts. Here are the steps to configure the execution order:

  1. Press the 'Execution Order...' button in the Inspector tab.

  2. Press the + button shown under the Default Time and select the KiiInitializeBehaviour.

  3. Set the loading time of the KiiInitializeBehaviour to a small value (like -100) so as to load the script faster than other scripts.

If you want to execute something right after the Kii Cloud SDK initialization, create a class that inherits the KiiInitializeBehaviour and write your codes after the base.Awake, like the following sample code. In this case, bind the MyKiiInitializeBehaviour, not the KiiInitializeBehaviour, to the empty game object.

public class MyKiiInitializeBehaviour : KiiInitializeBehaviour {
  public override void Awake()
    // The Kii Cloud SDK has been initialized.
    // You can call Kii Cloud APIs.

Using the SDK in multiple scenes

When you are using multiple scenes in your game, you just need to initialize the SDK with the KiiInitializeBehaviour once in the first scene.

  • All information initialized with the KiiInitializeBehaviour will not be garbage collected. The information will be retained when the scene changes to another one.

  • Executing the KiiInitializeBehaviour for the second time (and after that) does nothing. For example, executing the KiiInitializeBehaviour again in the first scene, after going to the second scene and going back to the first scene, will not initialize the SDK again.

Please note that you must bind the KiiInitializeBehaviour to the game object that is located at the root level. If not, the information initialized will be lost when the scene changes to another one.

Implementing scripts

Put the following declaration in all scripts that use the Kii Cloud SDK. This will allow the scripts to refer to the API.

using KiiCorp.Cloud.Storage;

Also, add the KiiCorp.Cloud.Storage.Connector or KiiCorp.Cloud.Analytics with "using" if you need these features. You can check the necessary namespace by using the auto-filing feature of the Mono Develop or by referring to the Monodoc.

Configuring the build

Here is a list of build options in Unity Player Settings that will affect Kii Cloud SDK.

  • API Compatibility Level

    Determines if you want to make API in your script compatible to .NET 2.0 or its subset. The configuration will affect the application size and start-up time.

  • Script Call Optimization

    Determines if you want to support an exception handling in iOS script. The configuration will affect the script execution speed.

  • Stripping Level

    Determines the level of code stripping to reduce the build size. The code stripping will remove unreferenced classes and methods from the script so as to shrink the main and DLL sizes.

  • Scripting Backend

    Determines if you want to execute your script in .NET Framework (Mono) or use IL2CPP to translate your code to C++ first and then execute. Using the IL2CPP will usually speed up the execution time and will allow you to select the iOS 64bit option (e.g., selecting ARM64 or Universal as Architecture).

The following table summarizes the combination of settings you can use with Kii Cloud SDK for Unity.


API Compatibility Level Script Call Optimization Stripping Level Supported
.NET 2.0 Slow and Safe Disabled Yes
Strip Assemblies
Strip ByteCode
Use micro microlib
Fast but no Exceptions Disabled Yes
Strip Assemblies
Strip ByteCode
Use micro microlib
.NET 2.0 Subset Slow and Safe Disabled Yes
Strip Assemblies Yes
Strip ByteCode Yes
Use micro microlib
Fast but no Exceptions Disabled Yes
Strip Assemblies Yes
Strip ByteCode Yes
Use micro microlib

When you are building the module for iOS 64bit, please select "IL2PP" for Scripting Backend and select either "ARM64" or "Universal" for Architecture.


API Compatibility Level Stripping Level Supported
.NET 2.0 Disabled Yes
Strip Assemblies
Strip ByteCode
Use micro microlib
.NET 2.0 Subset Disabled Yes
Strip Assemblies Yes
Strip ByteCode Yes
Use micro microlib