Information
This page is not available in Chinese yet.

# Integrating LINE Login with your Unity game

After you set up your project, you can start importing LINE SDK for Unity into your existing Unity game and leverage LINE Login to improve your app's user experience.

# Getting the SDK

# Download from GitHub

To get the latest LINE SDK for Unity, download the .unitypackage file from our GitHub Releases page (opens new window).

# Import into your project

Note

Before you import LINE SDK for Unity into your project, back up your project and/or store it in a version control system.

With your Unity project open, double-click on the downloaded .unitypackage file. Import everything in the package, as seen here:

Import Unity package

# Add LineSDK prefab to your scene

After importing the package, in your Project panel, you'll find a LineSDK prefab under Assets/LineSDK/. Drag it to the Hierarchy panel of the scene to which you want to add LINE Login:

Add LineSDK prefab

Then, click on the LineSDK GameObject in the scene, and update the Channel ID field with your LINE Login channel ID:

Set Channel ID

Find your LINE Login channel ID in the LINE Developers Console. If you don't have a channel yet, create one in the LINE Developers Console. You'll also have to select or create a provider.

# Update player settings

Before you continue to implement LINE Login or use LINE APIs in your game, follow the steps below to make sure your project player setting is correct.

# Settings for Android export

  1. Select File > Build Settings.
  2. Click Player Settings.
  3. Set Company Name and Product Name to the same value as Package names in your channel settings in the LINE Developers Console (LINE Login tab).
  4. Select the Android Settings tab.
  5. Under Other Settings:
    1. Set Package Name to the same value as Package names in the LINE Login tab of your channel in LINE Developer Console.
    2. Set Minimum API Level to at least API level 17.
  6. Under Publishing Settings, enable Custom Gradle Template.

# Settings for iOS export

  1. Select File > Build Settings.
  2. Click Player Settings.
  3. Select the iPhone, iPod Touch and iPad settings tab.
  4. Under Other Settings:
    1. Set Bundle Identifier to the same value as iOS bundle ID in the LINE Login tab of your channel in the LINE Developers Console.
    2. Set Target minimum iOS Version to at least 10.0.
  5. (Optional) If you want to use Carthage instead of CocoaPods:
    1. Open Unity Preferences.

    2. On the LINE SDK tab, update the iOS Dependency Manager field:

      Unity Preferences

For more about the dependency manager used in LINE SDK for Unity iOS, refer to Setting up your project.

# Implement login with LINE

Now, you can implement login with LINE in the scene where the LineSDK (GameObject) exists. For example:

using Line.LineSDK;

public class MyController : MonoBehaviour {
    public void LoginButtonClicked() {
        var scopes = new string[] {"profile", "openid"};
        LineSDK.Instance.Login(scopes, result => {
            result.Match(
                value => {
                    Debug.Log("Login OK. User display name: " + value.UserProfile.DisplayName);
                },
                error => {
                    Debug.Log("Login failed, reason: " + error.Message);
                }
            );
        });
    }
}

LINE SDK for Unity supports only iOS and Android for now. It will always return an error if you run it in Unity Editor play mode. To test it, you need to export your scene to either an iOS or Android device.

If you are using CocoaPods as your dependency manager, after building the game to an Xcode project, open the Unity-iPhone.xcworkspace file instead of the original Unity-iPhone.xcodeproj.