# Unreal Engine 4

通過以下鏈接下載ProudChat Unreal Engine 4 SDK。

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

## 項目設定

### - Plugins 設定

從項目根文件夾新建 Plugins 文件夾 。

將下載的SDK文件複製到生成的Plugins文件夾中。

<figure><img src="/files/rMhDPRu1F84EfFEPxCZ0" alt=""><figcaption></figcaption></figure>

在虛幻編輯器中<mark style="color:orange;">編輯</mark> - 單擊<mark style="color:orange;">插件</mark>以檢查從插件瀏覽器標籤中複製的 ProudChat 插件是否被激活。

<figure><img src="/files/rd0c3SB0fGPlyaQMuHoR" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
複製到 Plugins 文件夾後，如果在虛幻編輯器中看不到 ProudChat 插件，關閉編輯器後重新運行即可確認。
{% endhint %}

### - 藍圖類別設定

正確安裝插件後，將在虛幻編輯器的 <mark style="color:orange;">ProudChat C++ 類別</mark>瀏覽器中基於 ProudChatActor 類別建立藍圖類別。

<figure><img src="/files/osTRAuEIjQOETeQAwDYg" alt=""><figcaption></figcaption></figure>

在建立的藍圖類別的事件圖中，建立 Proud Chat 的 Init 函數並將其連接到 BeginPlay 事件，並輸入從 Proud Console 收到的<mark style="color:orange;">帳戶 UUID</mark>、<mark style="color:orange;">專案 UUID</mark> 和使用者 <mark style="color:orange;">UniqueID</mark>。

<figure><img src="/files/yYy7gEyXsJklqiEMPFU5" alt=""><figcaption></figcaption></figure>

點擊編譯按鈕編譯事件，將建立的藍圖類別上傳到關卡，然後按播放鍵檢查是否可以連接到伺服器。

<figure><img src="/files/YuKtRm6V47JD2JxQldmv" alt=""><figcaption></figcaption></figure>

如果連線成功，關卡左上角將顯示「ProudChat 連線成功」訊息。

<figure><img src="/files/OUFP5J2hgckB4BJXgAhb" alt=""><figcaption></figcaption></figure>

## ProudChatActor

### - ProudChatActor::Init

進行ProudChat Initialize的部分。 用戶在使用前必須調用Init函數與服務器連接。

<table data-full-width="true"><thead><tr><th width="140">函數名</th><th>參數</th><th>註釋</th></tr></thead><tbody><tr><td>Init</td><td><a href="https://console.nettention.com"><strong>Proud Console</strong></a>提供的<mark style="color:orange;">用戶的UUID</mark>、<mark style="color:orange;">用戶生成的項目的UUID</mark>、<mark style="color:orange;">用戶固有的UniqueID</mark></td><td>用戶編寫此部分作爲連接 ProudChat 的函數。 參數接收3個字符串， 但內部通過 std::bind 調用 <mark style="color:orange;">ChatClientInitComplete</mark>,  <mark style="color:orange;">ChatClientInitFailed</mark> 事件， 可確認登錄成功或失敗 。</td></tr></tbody></table>

### - 函數

<table data-full-width="true"><thead><tr><th width="199">函數名</th><th width="290">參數</th><th>註釋</th></tr></thead><tbody><tr><td>AddChannel</td><td>您想要訪問的頻道的固有Key</td><td>輸入您想要連接的通道的鍵。</td></tr><tr><td>LeaveChannel</td><td>您想要斷開的頻道的固有Key</td><td>輸入您想要解除連接的通道的鍵。</td></tr><tr><td>SendChannelMsg</td><td>特定頻道的獨特識別值， <br>要發送給特定頻道的消息</td><td>用於向特定頻道發送消息。</td></tr><tr><td>SendMsg</td><td>特定對方固有的識別值， <br>要發送給特定對象的消息</td><td>用於向特定對象發送消息。</td></tr></tbody></table>

### - 事件變數

<table data-full-width="true"><thead><tr><th width="297">事件變數名</th><th>註釋</th></tr></thead><tbody><tr><td>InitComplete_Delegate</td><td>Init Complete 完成時呼叫的事件</td></tr><tr><td>InitFailed_Delegate</td><td>成爲 Init Failed 時調用的事件</td></tr><tr><td>ChannelMsg_Response_Delegate</td><td>Channel Message 到達時調用的事件</td></tr><tr><td>SendMsg_Response_Delegate</td><td>Send Message 到達時調用的事件</td></tr><tr><td>Notice_Response_Delegate</td><td>當 Notice 到達時調用的事件</td></tr></tbody></table>

### - 事件函數

<table data-full-width="true"><thead><tr><th width="224">事件函數名</th><th>註釋</th></tr></thead><tbody><tr><td>ChatClientInitComplete</td><td>完成Server Connection後，成功到Login後被呼叫的函數。</td></tr><tr><td>ChatClientInitFailed</td><td>Server Login 失敗時調用的一個函數。 <br>使用此函數的時間是連接服務器成功但無法登錄賬戶時發生的事件 。 <br>失敗時不會重試，需要確認設置。</td></tr><tr><td>ChannelMsg_Response</td><td>其他用戶在信道上發送消息時Delegate的事件函數<br>用戶可以註冊並使用Event,註冊時<mark style="color:orange;">接收信息通道的Unique ID</mark>、<mark style="color:orange;">生成信息的對象的Unique ID</mark>、<mark style="color:orange;">對方發送的信息</mark>作爲參數。</td></tr><tr><td>SendMsg_Response</td><td>其他用戶向我發送消息時Delegate的事件函數<br>用戶可以註冊並使用Event，註冊時接收<mark style="color:orange;">產生信息的對象的Unique ID</mark>、<mark style="color:orange;">對方發送的信息</mark>作爲參數。</td></tr><tr><td>Notice_Response</td><td>Proud Console發送公告時Delegate的事件函數 <br>通過參數接收的信息輸出公告內容。</td></tr></tbody></table>

## 構建

### - Android

請參考以下鏈接。

{% hint style="info" %}
[<mark style="color:blue;">**Android quick start**</mark>](https://docs.unrealengine.com/5.3/zh-CN/setting-up-unreal-engine-projects-for-android-development/)
{% endhint %}

### - iOS

{% hint style="info" %}
請參考[**iOS的構建**](https://docs.proudnet.com/proudnet.cn/proudchat/download/pages/xm2T2pMYsD8LM8oJ2Vsb#4.-ios)。
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.proudnet.com/proudnet.cn/proudchat/download/unreal-engine-4.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
