Unity SDK

This page describes how to use the Game Chat Unity SDK.

Requirements

The specifications required to use the Game Chat Unity SDK are as follows.

  • Minimum specifications: 2018.4.0 or later (If you need support for the lower version of Unity, then make an inquiry through Contact us.)

  • If you are a user of Unity editor in the 2019.4.X/2020.3.X/2021.1.X version, then make sure to use a version at or above 2019.4.29f1/2020.3.15f2/2021.1.16f1 respectively (versions where the Unity editor bug is fixed when building the AAB version).

Install SDK and configure environment

The following describes how to download Game Chat Unity SDK and configure a project in Unity.

  1. Click the Settings > Download SDK menus, in that order, and then click Download Unity SDK.

  2. Run Unity, and create a project.

  3. In Unity, click the Assets > Import Package > Custom Package... menus, in that order.

  4. Open the "GameChatUnitySDK_xxxxxxxx" file downloaded in the dashboard.

  5. Select all files in the package, and then click the [Import] button.

  6. Save the project.

Authentication

Reset Game Chat instance

To initialize Game Chat instances using the Game Chat project ID, use the code below.

ID
type
desc

PROJECT_ID

string

Project ID

Connect to Game Chat socket server

The following describes how to connect to a Game Chat socket server.

  1. Use the chat user ID to access a Game Chat socket server.

    • In a Game Chat project, the chat user ID is a unique value.

  2. Get the token value for using the API.

    • The token value renewed can be viewed after GameChat.connect.

  3. After acquiring the token value, check if the chat user information is renewed for the currently connected device.

    • The member data received with the GameChat.connect's callback is renewed data.

Use the following code to connect to the Game Chat socket server.

ID
type
desc

USER_ID

string

Chat user's unique ID

Remove Game Chat server connection

To remove the connection with the Game Chat socket server, use the following code.

Chat user information update

Use the following code to save and update the chat user information after a successful connect.

Edit nickname

ID
type
desc

USER_ID

string

Chat user's unique ID

NickName

string

Chat user's nickname

Edit profile URL

ID
type
desc

USER_ID

string

Chat user's unique ID

ProfileUrl

string

Chat user's ProfileUrl

Subscribe and unsubscribe to channel

Use the following code to subscribe or unsubscribe to a specific channel.

ID
type
desc

CHANNEL_ID

string

Channel ID

Send message

Use the following code to send a message to a specific channel.

ID
type
desc

CHANNEL_ID

string

Channel ID

MESSAGE

string

Message text to send

When @[User ID] space [Message content] is entered for the MESSAGE parameter

In the above case, if the username has a history of being logged in, the "mentions" information from the message details is the user ID.

Register and remove event

Use the following code to register or remove a custom handler for events received from a Game Chat socket server.

Exceptions

The public class for exceptions occurring while using the Game Chat API is as follows.

Client API

Subscribe to channel

Subscription Data Class (per Unit)

ID
type
desc

id

string

Unique ID

channel_id

string

Channel ID

user_id

string

Chat user's unique ID

created_at

string

Creation date

Import channel subscription list

Use the following code to import the subscription data of a specific channel in the form of a list.

Channel

Channel Data Class (per Unit)

ID
type
desc

id

string

Channel ID (unique)

project_id

string

Project ID

unique_id

string

Channel ID that can be set by the developer (unique)

name

string

Channel name

user_id

string

Chat user ID (who created the channel)

created_at

string

Creation date

updated_at

string

Renewal date

Import channel list

Use the following code to import the channel data of a project in the form of a list.

ID
type
desc

OFFSET

int

Start location of the channel to import from the list of all channels (index)

LIMIT

int

Number of channels to import

Import channel data

Use the following code to import channel data using the channel ID and unique ID.

ID
type
desc

CHANNEL_ID

string

Channel ID (auto-generated)

CHANNEL_UNIQUE_ID

string

(Unique) channel ID (customization available)

Create and delete channel

You must use an open API to create or delete a new channel within a project. Due to security concerns, we recommend that you use an open API to create and update channels directly from Server to Server. For more information, see the Game Chat API Guide.

Messenger

(Received) Message Data Class (per Unit)

ID
type
desc

message_id

string

Message’s unique ID

channel_id

string

Channel ID

message_type

string

Message type

content

string

Content of message (JSON string)

mentions

string

Mention (tag)

created_at

string

Import message list

Use the following code to import the message data of a specific channel in the form of a list.

ID
type
desc

CHANNEL_ID

string

Channel ID

OFFSET

string

Start location of the message to import from the list of all messages

LIMIT

string

Number of messages to import

SEARCH

string

Message search criterion key. E.g., content.text Perform a full scan when sending empty strings

QUERY

string

Message search value. Only complete matches can be searched. Perform a full scan when sending empty strings

SORT

string

Message sorting order (default: descending order - most recent comes first) (optional: ascending order)

Translate messages

If the automatic translation feature is activated, then arbitrary text can be translated into the specified language. The automatic translation feature can be used after integrating with the Papago Translation service.

(Received) Translation Data Class (per Unit)

ID
type
desc

detectLang

string

Source language code

lang

string

Target language code

translated

bool

Success or failure of translation

message

string

Content of result message (JSON string)

Note

For more information on source language codes and target language codes, see the Papago Text Translation API Guide.

ID
type
desc

CHANNEL_ID

string

Channel ID

SORCE_LANG

string

Language name of the text to send ("auto": detected automatically) See the API Guide

TARTGET_LANG

string

Language code of the text (to receive the translation) (Multiple entries allowed with "," E.g., "en, fr, th") See the Papago Text Translation API Guide

TEXT

string

Text to send

Chat user

(Received) Member Data Class (per Unit)

ID
type
desc

id

string

Chat user's unique ID

project_id

string

Game Chat project ID that logged in

nickname

string

Chat user's nickname

profile_url

string

Profile image URL

country

string

Country connected

remoteip

string

Connection IP

adid

string

Advertisement identifier

device

string

Connected device's environment

network

string

Connected network's type (Cellular, Wi-Fi)

version

string

Version of the app connected

model

string

Connected device's model

logined_at

string

Login date

created_at

string

Chat user creation date

updated_at

string

Chat user information renewed date

Chat user information update

You can update the user information of a chat server.

ID
type
desc

MEMBER_ID

string

Chat user's unique ID

NAME

string

Chat user's nickname or name

PROFILE

string

Profile image URL

This helper class facilitates easy handling of emojis and hyperlink text included in the received message.

  • Since TMP_GameChatTextUGUI is an extension class of TextMeshPro, a built-in asset of Unity, you must use first use Package Manager to install TextMeshPro.

  • The TextMeshPro asset is included as a built-in asset from Unity 2018.2 or later.

  • The default output of emoji sprite sheets is available from Emoji v13.0 (Android). You can change and customize the sprite sheet.

<Example>

Last updated