Unity SDK

This explains how to use the GAMEPOT Unity SDK for game development in Unity. By installing the SDK and configuring the environment, you can integrate your game with the dashboard.

Requirements

The following are the requirements for using the GAMEPOT SDK for Unity:

  • Minimum Specification: Unity 2020.3.0 or later (If you require support for earlier versions of Unity, please contact us at [email protected].)

SDK Installation and Environment Configuration

After installing the GAMEPOT Unity SDK, you can configure the environment to integrate your game with the GAMEPOT dashboard and utilize features essential for game development.

The GAMEPOT SDK supports the following languages:

  • Korean, English, Italian, Thai, Vietnamese, Japanese, Chinese (Simplified/Traditional), Indonesian, German, Spanish, and French

The SDK displays content in the supported language based on the device's language settings when the app is launched. For unsupported languages, content will be displayed in English.

SDK Installation

How to Install and Configure the GAMEPOT Unity SDK in Unity

  1. Log in to the dashboard with an administrator account.

  2. Download the latest version from the official Unity distribution GitHub.

  3. In Unity, navigate to Assets > Import Package > Custom Package..., and import the nbase-unity-plugin-[version].unitypackage file.

  4. From GAMEPOT 3.0 onwards, the SDK is distributed via Maven and CocoaPods, allowing for integration with dozens of external libraries for each platform with simple configuration.

COCOAPODS

For iOS builds, CocoaPods must be installed for proper functionality.

It includes the External Dependency Manager for Unity, allowing you to conveniently install Android and iOS packages."

Android Gradle Settings

In Player Settings, make sure to check the boxes for Custom Main Gradle Template and Custom Gradle Properties Template under Publishing Settings.

Please increase the Minimum API Level to 23 (for compatibility with the androidx.security:security-crypto:1.0.0 encryption module).

Assets > External Dependency Manager > Android Resolver > Settings

  • Please uncheck the Enable Auto-Resolution and Explode AARs options.

Please open the file through the editor as shown in the image. You should be able to see a file like the one below.

The file below defines the dependency packages that are essential for using the NBase SDK. If you wish to use additional features, you can add them to this file, and the modules will be available on both Android and iOS.

What are Dependency Modules? Dependency modules are used for integrating external SDKs. For example, for Google login, you will need to install the module provided by Google, such as com.google.android.gms:play-services-auth.

If updates are available, minor version updates can be applied at any time. However, for major updates, please contact us before using them.

<?xml version="1.0" encoding="UTF-8"?>
<dependencies>
   <androidPackages>
       <androidPackage spec="io.nbase:nbasesdk:3.0.70"/>
       <androidPackage spec="com.google.code.gson:gson:2.10.1" />
       <androidPackage spec="androidx.security:security-crypto:1.0.0" /> 
       <androidPackage spec="com.apollographql.apollo3:apollo-runtime:4.0.0-beta.4" />
       <androidPackage spec="io.socket:socket.io-client:2.1.0" />
       <androidPackage spec="org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.6" />
   </androidPackages>
   <iosPods>		
       <iosPod name="Alamofire" version="5.8.1" minTargetSdk="9.0" />
       <iosPod name="Socket.IO-Client-Swift" version="16.1.0" minTargetSdk="9.0" />		
       <iosPod name="AppAuth" version="1.6.2" minTargetSdk="9.0" />
       <iosPod name="NBase" version="1.0.13" minTargetSdk="9.0" />
   </iosPods>
</dependencies>

For example, when using Google Login and Google Play Store payment.

<dependencies>
   <androidPackages>
       <androidPackage spec="io.nbase:nbasesdk:3.0.55"/>
       <androidPackage spec="com.google.code.gson:gson:2.10.1" />
       <androidPackage spec="androidx.security:security-crypto:1.0.0" /> 
       <androidPackage spec="com.apollographql.apollo3:apollo-runtime:4.0.0-beta.4" />
       <androidPackage spec="io.socket:socket.io-client:2.1.0" />
       <androidPackage spec="org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.6" />
       <androidPackage spec="io.nbase:nbase-adapter-provider-google:3.0.4"/>
       <androidPackage spec="io.nbase:nbase-adapter-billing-googleplay:3.0.3" />
       <androidPackage spec="com.google.android.gms:play-services-auth:20.7.0" />
       <androidPackage spec="com.android.billingclient:billing:6.1.0" />
   </androidPackages>
   <iosPods>
   	...
   </iosPods>
</dependencies>
Name
Version
Type
Dependeny modules

io.nbase:nbasesdk

3.0.70

Gamepot Basic Module

X

io.nbase:nbase-adapter-provider-google

3.0.4

Google Login

com.google.android.gms:play-services-auth:20.7.0

io.nbase:nbase-adapter-provider-apple

3.0.3

Apple Login

X

io.nbase:nbase-adapter-provider-facebook

3.0.3

Facebook Login

com.facebook.android:facebook-login:latest.release

io.nbase:nbase-adapter-provider-naver

3.0.1

NAVER Login

io.nbase:nbase-adapter-provider-line

3.0.1

Line Login

io.nbase:nbase-adapter-provider-x

3.0.1

X Login

io.nbase:nbase-adapter-billing-googleplay

3.0.3

Google Store

com.android.billingclient:billing-ktx:6.1.0

io.nbase:nbase-adapter-billing-one

3.0.1

ONEStore

io.nbase:nbase-adapter-billing-galaxy

3.0.1

Galaxdy Store

io.nbase:nbase-adapter-billing-amazon

3.0.1

Amazon Store

Email and guest login are applied to the basic module.

Automatic Configuration of NBaseSDKDependencies.xml

Through the dashboard → Settings → SDK Auto-Generation, a tool is provided to conveniently create tasks like this. You can also request the setup through our customer support center, and we will configure and provide it for you.

Click Assets > External Dependency Manager > Android Resolver > Force Resolve. After defining in the Dependencies.xml and clicking Force Resolve, the contents defined in the mainTemplate.gradle file will be automatically set as implementation, and this configuration will allow the related libraries to be retrieved during the build process.

iOS Settings

Settings in Tools > GamePotSDK > Edit Settings

Depending on the social login method, the necessary capabilities for the build, such as push notifications and in-app purchases, are also automatically configured.

Next, The XML file should be located under the Editor directory and must match the *Dependencies.xml format. Open the file at /Assets/NBaseSDK/Editor/NBaseSDKDependencies.xml.

You can add the required frameworks between "iosPods" and "/iosPods". The necessary frameworks are already added by default."

<?xml version="1.0" encoding="UTF-8"?>
<dependencies>
	<androidPackages>
        ...
	</androidPackages>
    <iosPods>
        <iosPod name="Alamofire" version="5.8.1" minTargetSdk="9.0" />
        <iosPod name="Socket.IO-Client-Swift" version="16.1.0" minTargetSdk="9.0" />		
        <iosPod name="AppAuth" version="1.6.2" minTargetSdk="9.0" />
        <iosPod name="NBase" version="3.0.11" minTargetSdk="9.0" />
    </iosPods>
</dependencies>

If you need to install frameworks like Firebase, you can add them separately as shown below.

<iosPods> 
       ...
        <iosPod name="FirebaseMessaging" version="10.20.0" minTargetSdk="9.0" />
        <iosPod name="Firebase/Analytics" version="10.15.0" minTargetSdk="9.0" />
        ...
</iosPods>

Assets -> External Dependency Manager -> iOS Resolver -> Install Cocoapods

Please be careful:

When building a Unity project for iOS, a Unity-iPhone.xcworkspace file is created, and you must open this file.

If you open Unity-iPhone.xcodeproj instead of Unity-iPhone.xcworkspace, the CocoaPods dependencies will not be used. Starting from Unity 2021, this project will be selected automatically.

Name
Version
Type
Dependeny modules

NBase

3.0.15

Gamepot Basic Module듈

X

NBaseAdapterProviderGoogle

3.0.1

Google Login

NBaseAdapterProviderFacebook

3.0.14

Facebook Login

FBSDKLoginKit (16.3.1)

NBaseAdapterProviderNaver

3.0.1

NAVER Login

NBaseAdapterProviderLine

3.0.1

Line Login

NBaseAdapterProviderX

3.0.1

X Login

NBaseAdapterBillingGoogleplay

3.0.1

Google Store

NBaseAdapterBillingOne

3.0.1

ONEStore

NBaseAdapterBillingGalaxy

3.0.1

Galaxy Store

NBaseAdapterBillingAmazon

3.0.1

Amazon Store

Adding the Apollo Package Manager

If you encounter the error No such module 'Apollo', please run the Swift Package Manager and add the Apollo framework.

Click the '+' button, then add the package collection with https://github.com/apollographql/apollo-ios.git. After that, select apollo-ios and choose Add Package. Finally, select Unity-iPhone.

Preparation

  1. The Project ID and Project Key can be copied from the Dashboard → Project Settings.

  2. The settings for login, store, and integration can all be added/modified in the Dashboard → Project Settings.

  3. For each login method, refer to [Login Authentication Settings], configure it in the console, and then add it to the dashboard.

  4. For in-app purchases, refer to [Store Settings], configure it in the console, and then add it to the dashboard.

  5. For each store where in-app purchases will be made, please register the items. Add them in Dashboard → Payments → In-App.

Initialization

To perform initialization, please add the following code to the object used in the first scene that loads when the game starts.

using UnityEngine;
using NBaseSDK;

 public class GamePotExample : MonoBehaviour
 {
     void Start()
     { 
       NBaseSDK.NBase.initialize(projectId, projectKey, [storeId], [language], [region], (init, error) => {
           if (error != null)
           {
               Debug.Log(error.Message);
               return;
           }
           Debug.Log(init.ToString());
       });
     }
 }
  • Parameter

Key
Description
Required

projectId

Dashboard → Project Settings

O

projectKey

Dashboard → Project Settings

O

storeId

Refer to the table below

O

language

Language (en,ko,jp...)

O

region

Region (kr, jp, sg, us, eu)

O

Key
Description

Store.google.ToString()

Google Store

Store.one.ToString()

ONEStore

Store.galaxy.ToString()

Galaxy Store

Store.amazon.ToString()

Amazon Store

Store.huawei.ToString()

Huawei Store

  • Callback

Key
Type
Description

Status

bool

Status

Language

string

Language

Country

string

Country

RemoteIp

string

IP

Sandbox

bool

Sandbox Mode

Initialization (Event Reception)

First, you need to create a script to receive NBase events. This script is called NBaseListener, and it can be placed on any object in the scene. It is recommended to call the DontDestroyOnLoad method to ensure that this object persists across scenes.

using UnityEngine;
using NBaseSDK;
public class NBaseListener: MonoBehaviour, NBaseEventListener
{
	void Start()
	{
        DontDestroyOnLoad(this.gameObject);
        NBaseSDK.NBase.SetEventListener(this);
    }	
}

Login

To use the SDK login functionality that activates when the login button is clicked on the custom login UI implemented by the developer, please use the following code. Before that, ensure that all necessary console and dashboard settings for login are completed for it to function correctly.


NBaseSDK.NBase.signIn(Provider.google.ToString(), (user, error) => {
    if (error != null)
    {
        if (error.code == MEMBER_WITHDRAW)
        {
            // Withdraw member
            Debug.Log(error.Message.ToString());    // 탈퇴 메시지
        }
        else if (error.code == APP_UPDATED)
        {
            // Forced Update
            Debug.Log(error.Message.ToString());    // 업데이트 안내 메시지
        }
        else if (error.code == MEMBER_BANNED)
        {
            // Access Block
            Debug.Log(error.Message.ToString());    // 차단 메시지
        }
        else
        {
            Debug.Log(error.Message.ToString());
        }
    else
    {
        // Login Success
        Debug.Log(user.ToString());
    }
    return;
});
  • Parameter

Key
Description

Provider.google.ToString()

Google

Provider.anonymous.ToString()

Guest

Provider.facebook.ToString()

Facebook

Provider.apple.ToString()

Apple

Provider.kakao.ToString()

Kakao

Provider.playgame.ToString()

Play Game

Provider.steam.ToString()

Steam

Provider.x.ToString()

X

Provider.line.ToString()

Line

Provider.naver.ToString()

NAVER

Provider.github.ToString()

Hithub

Provider.microsoft.ToString()

Microsoft

Provider.huawei.ToString()

Huawei

  • Callback

Key
Type
Description

Id

string

User Unique ID

Name

string

User Name

Email

string

User Email

Token

string

Token

Age

int

User Age

Birth

string

User Date of Birth

Sex

string

User Gender

Profile

string

User Profile

Mobile

string

User Phone Number

Metadata

string

MetaData

Auto Login(Optional)

After initialization, it will attempt to log in automatically using the last authenticated login method.

NBaseSDK.NBase.signInLastLoggedIn((user, error) => {
    if (error.code == MEMBER_WITHDRAW)
    {
        // Withdraw member
        Debug.Log(error.Message.ToString());    // 탈퇴 메시지
    }
        else if (error.code == APP_UPDATED)
    {
        // Forced Update
        Debug.Log(error.Message.ToString());    // 업데이트 안내 메시지
    }
    else if (error.code == MEMBER_BANNED)
    {
        // Access Block
        Debug.Log(error.Message.ToString());    // 차단 메시지
    }
    else
    {
        // Login Success
        Debug.Log(user.ToString());
    }
    return;
});

Custom ID and Password Authentication (Optional)

This authentication method allows users to log in using their email address and password. It performs user authentication based on the user's email address and password, playing a crucial role in traditional email/password-based authentication systems.

NBaseSDK.NBase.signInWithPassword(username, password, (user, error) => {
    if (error != null)
    {
        Debug.Log(error.Message.ToString());
        return;
    }
});

Login with Credentials (Optional)

This is used to handle user login with authentication credentials obtained through various methods (email and password, social media accounts, phone numbers, etc.). It helps easily implement different authentication methods and allows users to log in to Gamepot.

NBaseSDK.NBase.signInWithCredential(Provider.gamepot.ToString(), providerToken, (user, error) => {
    if (error != null)
    {
        Debug.Log(error.Message.ToString());
        return;
    }
});

Payment

Before making payments, ensure that the store-specific settings are configured according to the respective store. Additionally, if items are not added in Dashboard → Payments → In-App, the error "ProductID not found" will occur.

iOS StoreKit Settings

You need to create a new StoreKit file in Xcode.

Click the refresh button in front of 'Synced Today,' and the in-app information registered with Apple should be displayed as shown in the image.

Fetching In-App Information

When making a payment, you need to display the payment information and local currency details on the screen. You can retrieve the current payment currency, name, and other details using the function below. If you are unable to retrieve the information correctly, please check your console settings.

NBaseSDK.NBase.getProductItems(Store.google.ToString(), (products, error) => 
{
    if (products != null && products.Count > 0)
    {
        // 제품 목록을 순회합니다.
        foreach (var product in products)
        {
            // 각 제품의 정보를 토스트 메시지로 보여줍니다.
            // 예시에서는 product.ToString()을 호출하고 있지만,
            // 실제로는 product의 구체적인 속성(예: 이름, 가격 등)을 표시할 수 있습니다.
            NBaseSDK.NBase.showToast(product.ToString());
        }
    }
    else
    {
        // 제품 목록이 비어있는 경우, 사용자에게 알립니다.
        NBaseSDK.NBase.showToast("제품 목록이 비어있습니다.");
    }
});
  • Callback

Key
Type
Description

Products[].Id

string

Product ID

Products[].Name

string

Product Name

Products[].Price

double

Product Price

Products[].Description

string

Product Description

Products[].LocalizedPrice

string

Localized Price

Products[].Currency

string

Product Currency Unit

Payment Request

You can request a payment using the productId from the fetched in-app information.

NBaseSDK.NBase.purchase(Store.google.ToString(), [productId], [metadata], [options], (purchase, error) => 
{
    if (error != null)
    {
        Debug.Log(error.Message.ToString());
        return;
    }
    // Payment Success
});
  • Parameter

Key
Description
Required

ProductId

Product ID (Dashboard → Payments → In-App Items)

O

Metadata

Metadata

X

Options

Payment Option Features

X

Key
Description

Store.google.ToString()

Google Store

Store.one.ToString()

ONEStore

Store.galaxy.ToString()

Galaxy Store

Store.amazon.ToString()

Amazon Store

Store.huawei.ToString()

Huawei Store

  • Callback

Key
Type
Description

storeId

string

Store Unique ID

paymentId

string

Payment ID

iapVersion

string

In-App Billing Version

productId

string

Product ID

billingKey

string

Billing Key

signature

string

Signature

originalJson

string

Original JSON

orderId

string

Order ID

developerPayload

string

Developer Payload

packageName

string

Package Name

isAcknowledged

bool

Verification Status

purchaseState

int

Purchase State

purchaseTime

long

Purchase Time

price

float

Price

quantity

int

Quantity

currency

string

Currency Unit

Unity Standalone Guide

Standalone refers to builds for Mac, Windows, and Linux. The Gamepot SDK supports cross-platform development, but the features supported on mobile and Standalone platforms differ. Please refer to the table below to plan your development accordingly.

Service
Android
iOS
Web
PC

Login

O

O

O

PC Login and Token Verification

Payment

O

O

O

Move to PC Payment

Notice

O

O

O

O

Customer Support

O

O

O

O

Leaderboard

O

O

O

O

Friend Management

O

O

O

O

Push

O

O

X

X

Maintenance

O

O

O

O

Update

O

O

O

O

Coupons

O

O

O

O

Chat

O

O

O

O

Data Storage

O

O

O

Coming Soon

Security

O

O

X

Coming Soon

Player

O

O

O

Coming Soon

Web 3.0 Guide

The Web version is a feature available only for the GamePot 3.0 TypeScript version.

Newtonsoft.Json Conflict

The NBase Unity SDK uses Unity's Newtonsoft Json package for API request parsing. Since Json is one of the most commonly used libraries, there is a possibility of encountering library duplication errors if a Json library is already present in the project.

In this case, you can either delete the Newtonsoft.Json file in the Plugins/Standalone directory or remove the existing Json library from the project and use Unity's built-in Json package. Unity's Json package has been modified to work with the Unity engine and is a version that fully supports IL2CPP.

Troubleshooting

Q. UnityPlayerActivity.java uses or overrides a deprecated API.

A. Go to Edit → Project Settings → Player → Publishing Settings and check the Custom Properties Gradle Template option..

Q. error:1E08010C:DECODER routines::unsupported

A. If there is a mismatch in the Google Authentication Key value, refer to the Google Play Store guide and ensure the key is entered correctly.

Q. When trying to download from official Maven repositories like OneStore or Gamepot Beta, or from maven or jitpack.io, Unity shows an error.

Could not determine the dependencies of task ':unityLibrary:compileReleaseAidl'.
> Could not resolve all task dependencies for configuration ':unityLibrary:releaseCompileClasspath'.
   > Could not find io.nbase:nbasesdk:0.0.71-beta.
     Required by:
         project :unityLibrary

For modules that do not use public Maven, you need to specify the Maven repository address as follows:

You can add the Maven repository address in the NBaseSDKDependencies file when configuring it.

# ONEstore
<androidPackage spec="com.onestorecorp.sdk:sdk-iap:21.01.00"/>
    <repositories>
        <repository>https://repo.onestore.co.kr/repository/onestore-sdk-public</repository>
    </repositories>
</androidPackage>

# NBase Beta maven Repository
<androidPackage spec="io.nbase:nbasesdk:3.0.39-beta.1"/>
    <repositories>
        <repository>https://repo.nbase.io/repository/nbase-releases/</repository>
    </repositories>
</androidPackage>

You can also add the address for jitpack.io as shown above.

Q. Minimum API Level Upgrade Notice

A. Please upgrade the API Level from the default 22 to 24.

Q. Authorization failed: Error Domain=AKAuthenticationError Code=-7026

A. Click TARGETS > +Capability and add Sign in with Apple.

Q. Couldn't get credential from result.10: Developer console is not set up correctly

A. This error may occur if the client ID for the web application type is not set in Google Cloud Console > Credentials > OAuth 2.0 Client ID.  Q. 16: Cannot find a matching credential.

A. This error may occur if the OAuth 2.0 Client ID is not registered in Google Cloud Console > Credentials. Q. java.lang.NoClassDefFoundError: Failed resolution of: Lcom/android/billingclient/api/BillingClient;

A. Please add the following code.

<androidPackage spec="com.android.billingclient:billing:6.1.0" /> 

Q. (iOS) A crash occurs when the app is launched, and the error "/AdapterProviderFacebook' (no such file)" is found.

A. Add AdapterProviderFacebook.xcframework in Xcode TARGETS → General → Frameworks, Libraries, and Embedded Content.

Q. If you encounter the error '/usr/lib/swift/NBase.framework/NBase' (no such file, not in dyld cache) after running the app, please add NBase.xcframework as follows.

Q. (iOS) The error "NSBundle file:///System/Library/Frameworks/Metal.framework/ principal class is nil because all fallbacks have failed" occurs in the iOS 18 environment.

A. Open the Edit Scheme window (shortcut: CMD + SHIFT + ,) and uncheck the 'API Validation' option under the Metal section, as shown below.

Last updated