# Unity3D

如果將ProudNet安裝路徑中的<mark style="color:orange;">lib/Plugins</mark>資料夾和檔案放入Unity專案路徑中的<mark style="color:orange;">Assets/Plugins</mark>中，則ProudNet程式庫將包含在專案中。

詳細流程如下。

## 1. 複製並貼上 plugins

<figure><img src="/files/YgaQfRzhWS6Lv6yHn1H2" alt=""><figcaption><p>進入ProudNet安裝路徑</p></figcaption></figure>

從 ProudNet 安裝路徑複製外掛程式。

<figure><img src="/files/ceIAAPwU2rjjRb66TABi" alt=""><figcaption><p>Unity專案路徑</p></figcaption></figure>

將複製的檔案貼到要使用 ProudNet 的 Unity 專案的 Plugins 資料夾中。

## 2.  插件常用設定

### - x86, x86\_64 插件選擇

{% hint style="info" %}
下圖是使用x86\_64外掛程式刪除x86資料夾的範例。
{% endhint %}

<figure><img src="/files/fFRqGzciOXowjjD0D7ZH" alt=""><figcaption><p>刪除Unity專案路徑中Plugins資料夾內的x86資料夾。</p></figcaption></figure>

{% hint style="danger" %}
刪除 x86 資料夾，因為如果保留未使用的 x86 資料夾，可能會與 <mark style="color:orange;">x86\_64</mark> 的內容重疊。
{% endhint %}

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

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

透過更改 <mark style="color:orange;">x86\_64</mark> 內的插件檔案設定來使用它。

### -  在 Stripped 資料夾中選擇插件

如果你檢查Unity專案中的Plugins資料夾，會發現外掛程式如下圖。 剝離資料夾內的插件和外面的插件是一樣的，只是剝離資料夾內的插件帶有**符號**，兩種插件中只保留自己需要的插件，刪除即可您不使用的插件。

{% hint style="warning" %}
下圖是刪除剝離資料夾以使用不包含符號的插件的範例。
{% endhint %}

{% hint style="danger" %}
如果您不刪除已剝離資料夾中的插件以及外部插件之一，則可能會在建置時出現錯誤。
{% endhint %}

<figure><img src="/files/1YFSQa0iEMqj55uNh9x6" alt=""><figcaption><p>刪除 libs -> arm64-v8a -> stripped 資料夾。</p></figcaption></figure>

<figure><img src="/files/7GKva5VUJqCsvH1PjTBU" alt=""><figcaption><p>刪除 libs ->armeabi-v7a ->stripped 資料夾。</p></figcaption></figure>

<figure><img src="/files/zzBUA8SUPJkHUMfth2Lc" alt=""><figcaption><p>libs -> x86 -> strippe刪除 libs -> x86 -> stripped 資料夾。</p></figcaption></figure>

## 3. 根據使用環境進行插件設置

### - Mac

<figure><img src="/files/Krpbk6WU290P4XGHP9dY" alt=""><figcaption><p>Mac - ProudDotNetClientUnity</p></figcaption></figure>

<figure><img src="/files/64UD78SBUxEd6ImbAPAP" alt=""><figcaption><p>Mac - ProudDotNetClientUnity</p></figcaption></figure>

<figure><img src="/files/z6lPracvrvykvCHAkqBH" alt=""><figcaption><p>Mac - ProudNetClientPlugin</p></figcaption></figure>

<figure><img src="/files/ATVcfEYr4QDeaEmBUXWS" alt=""><figcaption><p>Mac - ProudDotNetClientUnity-IOS</p></figcaption></figure>

您可以使用預設設定的其他插件，但對於 iOS，您必須按照上圖所示設定插件。

### - Windows 或 Android

在 Windows 或 Android 環境中，插件設定如下進行。

<figure><img src="/files/ThCQ1ZBKGp1gzKVr8zD3" alt=""><figcaption><p>ProudDotNetClientUnity-IOS</p></figcaption></figure>

<figure><img src="/files/B0KQLfq9MtFK6JgY1pKX" alt=""><figcaption><p>Window - ProudDotNetClientUnity</p></figcaption></figure>

<figure><img src="/files/bmKRrHniPATjnpZeio85" alt=""><figcaption><p>Window - ProudDotNetClientUnity</p></figcaption></figure>

<figure><img src="/files/3NARW2OPxvBz51PtVmqf" alt=""><figcaption><p>Window - ProudDotClienPlugin</p></figcaption></figure>

### - WebGL

<mark style="color:orange;">/Assets/Plugins/WebGL</mark>下有<mark style="color:orange;">WebGL</mark>相關的插件。

Unity 將自動識別 <mark style="color:orange;">WebGL</mark> 以使用該插件進行建置。 如果不是<mark style="color:orange;">WebGL</mark>環境，則不應建置包括<mark style="color:orange;">WebGL</mark>在內的其他外掛程式。

如果出&#x73FE;***'XXX' could not be found.***&#x7B49;錯誤，則表示<mark style="color:orange;">WebGL</mark>相關插件沒有正確添加，如果出&#x73FE;***'XXX' already defined.***&#x7B49;錯誤，則表示與其他外掛程式有衝突。

選擇插件並設定要在建置 <mark style="color:orange;">WebGL</mark> 時包含的 <mark style="color:orange;">JSClient.jslib</mark> 和 <mark style="color:orange;">ProudNetClientPlugin-webgl.dll</mark>，如Inspector視窗中所示。

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

<figure><img src="/files/5KtRv20NALJTmt9B6k5D" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
為了防止在建立 WebGL 時包含其他插件，請停用任何平台並僅檢查所需的平台。
{% endhint %}

## 4. 創建腳本

<figure><img src="/files/1r4MU0e6Z5JzFZtgdQ8U" alt=""><figcaption></figcaption></figure>

一切設定完畢後，建立一個腳本來建立 <mark style="color:orange;">NetClient</mark>。

<figure><img src="/files/j80k0F23p9KPW3fHP8e2" alt=""><figcaption><p>用作客戶端的 cs 文件</p></figcaption></figure>

如上例，<mark style="color:orange;">NetClient</mark>可以正常創建，不會出現編譯錯誤。

<figure><img src="/files/Oa2Iq46iT8V6qtpw6VM2" alt=""><figcaption><p>將 GameClient.cs 作為元件加入空遊戲物件的範例</p></figcaption></figure>

您可以使用以這種方式建立的腳本文件，將其作為組件添加到要用作客戶端的遊戲物件中。

## 5. IOS 建置

{% hint style="info" %}
有關 iOS，請參閱 [**iOS 建置**](/proudnet.cn/proudnet/2.setting/unity3d/ios-jian-zhi.md)。
{% endhint %}

***

## :arrow\_left: [返回](https://docs.proudnet.com/proudnet.cn/proudnet/2.setting/pages/YF7Z3CPCxDI0T1hoMsHR#2.-pidl)


---

# 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/proudnet/2.setting/unity3d.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.
