最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

ET 7 入門文檔(登錄)

2023-08-04 02:30 作者:LULU狗_0596  | 我要投稿

目錄

一. 客戶端

????1.編譯運(yùn)行

????2.創(chuàng)建UI

????3.編寫UI代碼

????4.發(fā)送接收消息

? ? 5.編寫協(xié)議

二. 服務(wù)器

????1.發(fā)送接收消息

一.客戶端

1.編譯運(yùn)行

1.1打開 ET 打包工具

????·如圖1-1,在 Unity?頂部菜單選擇 ET -> Build Tool,打開 ET.BuildEditor 窗口.

圖1-1?ET 菜單

1.2編譯? ?

如圖1-2,CodeMode 選擇 ClientServer, 點(diǎn)擊 BuildModelAndHotfix.

圖1-2 ET.BuildEditor

????如圖1-3,顯示編譯成功.

圖1-3 BuildModelAndHotfix Success Log

1.3運(yùn)行?? ????

????如圖1-4,在 Assets/Scenes 下 雙擊打開 Init 場景.

圖1-4 Init.unity

????如圖1-5,點(diǎn)擊運(yùn)行按鈕,可以看到正常打開了 Login?界面.

圖1-5 Login 界面運(yùn)行

2.創(chuàng)建UI

????如圖1-6,打開 Asset/Bundles/UI,點(diǎn)擊 UILogin ,Ctr + C 進(jìn)行拷貝.

圖1-6 UILogin

????如圖1-7,在??Asset/Bundles/UI 目錄下創(chuàng)建目錄 Demo/Login,Ctr + V 將 UILogin?拷貝進(jìn)來,并改名為 UILoginNew.

圖1-7 UILoginNew

????如圖1-8,點(diǎn)擊?UILoginNew,在其?Inspector 窗口最底部,找到 AssetBundle,點(diǎn)擊 uilogin.unity3d.

圖1-8 UILogin Inspector AssetBundle

????如圖1-9,彈出選項(xiàng),點(diǎn)擊 New... ,并取名為 uiloginnew.unity3d.

圖1-9 Asset Name

????結(jié)果,如圖1-10.

圖1-10 uiloginnew.unity3d

3.編寫UI代碼

3.1打開代碼工程

????如圖1-11,在項(xiàng)目根目錄,雙擊打開 ET.sln.

圖1-11 ET.sln

3.2編寫?UIComponent????

????如圖1-12,打開 ET/Unity/Unity.ModelView/Assets/Scripts/Codes/ModeView/Client/

Demo/UI,創(chuàng)建一個(gè)文件夾,取名 UILoginNew,拷貝 UILoginComponent 到 UILoginNew,更改文件名為 UILoginNewComponent.

圖1-12 Component

????雙擊?UILoginNewComponent.cs,將 UILoginComponent 替換為 UILoginNewComponet:

3.3編寫?UIComponentSystem? ??????

????如圖1-13,打開?ET/Unity/Unity.HotfixView/Assets/Scripts/Codes/HotfixView/Client/

Demo/UI,創(chuàng)建一個(gè)文件夾,取名 UILoginNew??截?

????LoginFinish_RemoveLoginUI ->?LoginFinish_RemoveLoginNewUI?

????UILoginComponentSystem ->?UILoginComponentNewSystem?

????UILoginEvent -> UILoginNewEvent

圖1-13 System

????雙擊打開?UILoginNewEvent,不需要了解該部分代碼,將對應(yīng)名字進(jìn)行全部替換:

?????UILoginEvent -> UILoginNew

????UIType.UILogin?->?UIType.UILoginNew,

????ui.AddComponent<UILoginComponent> ->?ui.AddComponent<UILoginNewComponent>

? ? 此時(shí) UIType.UILoginNew 不存在,找到 ET/Unity/Unity.ModelView/Assets/Scripts/

Codes/ModeView/Client/Demo/UI/UIType.cs,在底部添加代碼:

????public const string UILoginNew = "UILoginNew";

????雙擊打開?LoginFinish_RemoveLoginNewUI?不需要了解該部分代碼,將對應(yīng)名字全部進(jìn)行替換:

? ? LoginFinish_RemoveLoginUI -> LoginNewFinish_RemoveLoginNewUI

????UIType.UILogin ->?UIType.UILoginNew

? ? 雙擊打開 UILoginComponentSystem,不需要了解該部分代碼,將對應(yīng)名字全部進(jìn)行替換:

????UILoginComponentSystem ->?UILoginComponentNewSystem

????UILoginComponentAwakeSystem ->?UILoginComponentNewAwakeSystem?

????UILoginComponent ->?UILoginNewComponent

????LoginHelper.Login -> LoginHelper.LoginNew

4.客戶端發(fā)送接收消息??? ??

????此時(shí) LoginHelper.LoginNew() 還不存在,找到ET/Unity/Unity.Hotfix/Assets/Scripts/

Codes/Hotfix/Client/Demo/Login/LoginHelper.cs,在里面添加一個(gè)新的方法:

5.編寫協(xié)議?

????此時(shí)C2R_LoginNew 和?R2C_LoginNew 不存在。如圖1-14,找到 Assets/Config/Proto,右鍵在VsCode 的打開 OutMessage_C_10001.proto,這里編寫外網(wǎng)消息.

圖1-14 OuterMessage

????在最底下添加下列代碼:?

? ? 如圖1-15 打開 ET.BuildEditor,點(diǎn)擊 Proto2CS,生成協(xié)議的 C# 代碼。此時(shí)?LoginHelper 中的?C2R_LoginNew 和?R2C_LoginNew 將不報(bào)錯(cuò).

圖1-15 Pro2CS

二.服務(wù)端

1.發(fā)送接收消息? ??

????如圖2-1,打開 ET/Unity/Unity.Hotfix/Assets/Scripts/Codes/Hotfix/Server/Demo/

Scenes/Realm,拷貝C2R_LoginHandler -> C2RLoginNewHandler

圖2-1?Server Handler

????更改相應(yīng)名字,刪除內(nèi)部實(shí)現(xiàn),替換為:

????response.Message = "這是一條服務(wù)器消息";
????await ETTask.CompletedTask;

????至此,所有代碼均編寫完成,返回 Unity ,點(diǎn)擊??ET.BuildEditor 的 BuildModelAndHotfix 按鈕,重寫編譯程序.

????點(diǎn)擊運(yùn)行,點(diǎn)擊登錄按鈕,如圖2-2:即可在控制臺看到客戶端與服務(wù)器的消息傳輸,并成功在客戶端接收到服務(wù)器的消息反饋

圖2-2?消息通訊


ET 7 入門文檔(登錄)的評論 (共 條)

分享到微博請遵守國家法律
宁南县| 天峻县| 阳新县| 阜康市| 棋牌| 乐陵市| 县级市| 定西市| 尉犁县| 安西县| 自贡市| 罗田县| 闽清县| 华阴市| 屏山县| 望江县| 西藏| 隆回县| 江都市| 宜兰县| 陆丰市| 兴国县| 布尔津县| 简阳市| 庐江县| 兴山县| 白城市| 巧家县| 青冈县| 芒康县| 呼玛县| 海宁市| 四川省| 图片| 德州市| 孟津县| 申扎县| 临猗县| 沂源县| 勃利县| 崇左市|