Unity


This section explains the configuration and initialization effort required for SDK integration of Unity game.

1.SDK Integration

1.1.Import SDK to your game project

1.2.Setup App Key and Secret

1.3.Add KTplay Prefab to your Scene

1.4.Integrate Key Feature Modules

2.Points to be Aware

2.1. Compatible with Unity Editor

2.2. Supports For iOS 10.0

2.3 Setup KTplay Window Orientation

1. SDK Integration

Step 1. Import SDK to your game project

  • Download and unzip SDK

  • Import KTPlay.unitypackage from SDK folder

Step 2. Setup App Key and Secret

In Unity, open file Assets/KTPlay/Scripts/KTSettings, and fill in the app key and secret obtained from KTplay portal.

/// <summary>
///   KTplay AppKey & AppSecret [Required]
/// </summary>

#if UNITY_ANDROID
public  string AppKey = "Your Android App Key";
public  string AppSecret = "Your Android App Secret";
#elif UNITY_IOS
public  string AppKey = "Your iOS App Key";
public  string AppSecret = "Your iOS App Secret";
#else
#endif

Step 3. Add KTplay Prefab to your Scene

Drag and drop the KTPlay prefab found at /Assets/KTPlay/KTPlay to your Unity scene in the Scene view.

This Prefab will automatically handle basic SDK behavior like initialization.

Step 4. Integrate Key Feature Modules

After finished above steps, you can start integrate required feature such as Community, In-Game Messaging. Features integration guide are listed here.

2. Points to be Aware

2.1 Compatible with Unity Editor

KTplay features will work on iOS/Android device only, that is, when under Unity 's Editor mode, KTplay features will be disabled, but will not affect game operation.

2.2 Supports For iOS 10.0

From Apple's announcement, To protect user privacy, an iOS app linked on or after iOS 10.0, and which accesses the user’s photo library,must statically declare the intent to do so. Include the NSPhotoLibraryUsageDescription key in your app’s Info.plist file and provide a purpose string for this key. If your app attempts to access the user’s photo library without a corresponding purpose string, your app exits.

  • Open project's info.plist (Open As Property List)
  • Add new field NSPhotoLibraryUsageDescription as String, and set value to following content:
    Allow access your photos so you can share them with other players.

The following is an example of modified info.plist (Open As Source Code).

    <key>NSPhotoLibraryUsageDescription</key>
    <string>Allow access your photos so you can share them with other players.</string>

2.3 Setup KTplay Window Orientation

In Unity, open file Assets/KTPlay/Scripts/KTSettings, and setup ScreenOrientation.


    public enum KTScreenOrientation
    {
        
        Auto = 0,
        Portrait,
        Landscape,

    };
    public static KTScreenOrientation ScreenOrientation = KTScreenOrientation.Auto;

For Android, KTplay window's orientation will be aligned with game's screen orientation which configured in AndroidManifest.xml.

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.