# Unity3D

Download the ProudChat Unity SDK from the link below.

## :open\_file\_folder: [Unity ProudChat SDK](https://github.com/Nettention/ProudChatSDK/tree/main/ChatClientSDK/Unity)

## Project settings

### Add Unity PackageFile

ProudChatUnityPackage downloaded via git Add the Package via <mark style="color:orange;">Assets</mark> -> <mark style="color:orange;">Import Package</mark> -> <mark style="color:orange;">custom Package</mark> at the top of the Unity Editor.

<figure><img src="https://content.gitbook.com/content/Ceg6wWD81CFYby05yPX5/blobs/vOQjYHAar0RZYZfvVuSt/unity%20sdk0.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://content.gitbook.com/content/Ceg6wWD81CFYby05yPX5/blobs/uc2NZuxykPEMdZuV9BRo/unity%20sdk1.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://content.gitbook.com/content/Ceg6wWD81CFYby05yPX5/blobs/QUku1Hwa7BHCgiqSJHdK/packageimport.png" alt=""><figcaption><p>Import all  the package files.</p></figcaption></figure>

### Setting up plugins

{% hint style="info" %}
Please see [**Plugin settings.**](https://docs.proudnet.com/proudnet.eng/proudnet/2.setting/unity3d#mac)
{% endhint %}

##

## ProudChatComponent

The <mark style="color:orange;">ProudChatComponent</mark> makes it easy for users to get each of the features they need for chat.

{% hint style="danger" %}
Be sure to register and use only one Component.
{% endhint %}

### - ProudChat\_Init

This is the part that initializes the ChatClient. The user must call the Init function to connect to the server before using it.

<table data-full-width="false"><thead><tr><th width="164">Function Name</th><th width="215">Parameters</th><th>Description</th></tr></thead><tbody><tr><td>ProudChat_Init</td><td>The user's UUID from the <a href="https://console.nettention.com"><strong>Proud Console</strong></a>, the UUID of the project the user created, and the user's own UniqueID.</td><td>You write this part as a function to connect the ChatClient with the server.<br>We're getting 3 strings as parameters, but internally we're calling the <mark style="color:orange;">ChatClientInitComplete</mark>, <mark style="color:orange;">ChatClientJoinFailed</mark> functions so we can see if the login was successful or unsuccessful.</td></tr></tbody></table>

### - Disconnect

<table data-full-width="false"><thead><tr><th width="186">Function Name</th><th width="206">Parameters</th><th>Description</th></tr></thead><tbody><tr><td>Disconnect</td><td>-</td><td>Use when you want to disconnect with the chat server.</td></tr></tbody></table>

### - Function

<table data-full-width="false"><thead><tr><th width="204">Function Name</th><th width="317">Parameters</th><th>Description</th></tr></thead><tbody><tr><td>IsConnected</td><td>-</td><td>Use when you check the status of server connection.</td></tr><tr><td>Join_Channel</td><td>Unique key for the channel you want to access</td><td>Use when you want to access a specific channel.</td></tr><tr><td>Leave_Channel</td><td>Unique key for the channel you want to leave</td><td>Use this when you want to leave the channel you're in.</td></tr><tr><td>Send_Direct_Msg</td><td>A unique identification value for a specific recipient, a message to send to the specific party</td><td>Use to send a message to a specific person.</td></tr><tr><td>Send_Channel_Msg</td><td>A unique identification value for a specific channel, a message to send to the specific channel</td><td>Use to send a message to a specific channel.</td></tr><tr><td>MsgTranslate</td><td><p>src = The country code of current language</p><p>target = The country code of the targeting language</p><p>msgKey = A unique key of message to translate</p><p>msg = A message to translate</p></td><td>(Beta) Use when you want to translate the message</td></tr><tr><td>MsgTranslate_Auto</td><td><p>target = The country code of the targeting language</p><p>msgKey = A unique key of message to translate </p><p>msg = A message to translate</p></td><td>(Beta) Request the translation of the message after automatically detecting the language.</td></tr><tr><td>MsgRecord_Channel</td><td>channelKey = A unique key of the channel<br>day = The days (max 90)<br>cnt = The counts (max 100)</td><td>(Beta) Request the chat data from the Channel. <br>Retrieve up to 100 messages within the last 90 days.</td></tr><tr><td>MsgRecord_Direct</td><td>target = A unique key of the target user<br>day = The days (max 90)<br>cnt = The counts (max 100)</td><td>(Beta) Request the data from the Direct messages.<br>Retrieve up to 100 messages within the last 90 days.</td></tr><tr><td>MsgRecord_Notice</td><td>day = The days (max 90)<br>cnt = The counts (max 100)</td><td>(Beta) Request the data from the Notice.<br>Retrieve up to 100 messages within the last 90 days.</td></tr></tbody></table>

### - Event Variables

<table data-full-width="false"><thead><tr><th width="311">Event function name</th><th>Description</th></tr></thead><tbody><tr><td>m_ClientInitComplete_Event</td><td>Event fired when ChatClient completes <mark style="color:orange;">Init</mark>.</td></tr><tr><td>m_ClientInitFailed_Event</td><td>Event fired when ChatClient <mark style="color:orange;">Init Failed</mark> occurs.</td></tr><tr><td>m_ChatDisconnect_Event</td><td>Event fired when the chat server <mark style="color:orange;">disconnected</mark>. </td></tr><tr><td>m_DirectMsg_Response_Event</td><td>It handles events if the <mark style="color:orange;">DirectMsg</mark> arrives between users.</td></tr><tr><td>m_ChannelMsg_Response_Event</td><td>It handles events that occur if a <mark style="color:orange;">ChannelMsg</mark> arrives.</td></tr><tr><td>m_Notice_Response_Event</td><td>It will be called when you send <mark style="color:orange;">Notice</mark> from Proud Console.</td></tr><tr><td>m_Channel_Join_Success_Event</td><td>It will be called if <mark style="color:orange;">Channel Join Success</mark> occurs.</td></tr><tr><td>m_Channel_Join_Failed_Event</td><td>It will be called if <mark style="color:orange;">Channel Join Failed</mark> occurs.</td></tr><tr><td>m_Channel_Leave_Success_Event</td><td>It will be called if <mark style="color:orange;">Channel Leave Success</mark> occurs.</td></tr><tr><td>m_Channel_Leave_Failed_Event</td><td>It will be called if <mark style="color:orange;">Channel Leave Failed</mark> occurs.</td></tr><tr><td>m_Msg_Translate_Success_Event</td><td>(Beta) It will be called if the message is successfully translated.</td></tr><tr><td>m_Msg_Translate_Failed_Event</td><td>(Beta) It will be called if the message translation fails.</td></tr><tr><td>m_Msg_Record_Success_Event</td><td>(Beta) It will be called if the data history is successfully retrieved.</td></tr><tr><td>m_Msg_Record_Failed_Event</td><td>(Beta) It will be called if the data history retrieval fails.</td></tr></tbody></table>

## Building

### - Android

{% hint style="success" %}
See [**Selecting plugins in the Stripped folder**](https://docs.proudnet.com/proudnet.eng/proudnet/2.setting/unity3d#stripped).&#x20;
{% endhint %}

### - iOS

{% hint style="success" %}
For more information, see [**Building iOS**](https://docs.proudnet.com/proudnet.eng/proudnet/2.setting/unity3d/ios-build).
{% endhint %}
