上一篇 [2] ET架構初養成 mac OS第一次啟動Demo
下一篇 [4] ET架構初養成 mac OS .proto 添加[注冊并登陸]協定
在win10環境下 Tools/Proto2CS是可以直接使用的,但是Mac下就有點曲折
點選生成Protocol Buffer報錯
Win32Exception: ApplicationName='dotnet', CommandLine='Proto2CS.dll', CurrentDirectory='../Proto/', Native error= Cannot find the specified file
System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) (at <3845a180c26b4889bc2d47593a665814>:0)
System.Diagnostics.Process.Start () (at <3845a180c26b4889bc2d47593a665814>:0)
(wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo) (at <3845a180c26b4889bc2d47593a665814>:0)
ETModel.ProcessHelper.Run (System.String exe, System.String arguments, System.String workingDirectory, System.Boolean waitExit) (at Assets/Model/Base/ProcessHelper.cs:42)
Rethrow as Exception: dir: /Users/luwenyi/Work/GitHub/Unity/ET_Base/ET/Proto/, command: dotnet Proto2CS.dll
ETModel.ProcessHelper.Run (System.String exe, System.String arguments, System.String workingDirectory, System.Boolean waitExit) (at Assets/Model/Base/ProcessHelper.cs:57)
ETEditor.Proto2CSEditor.AllProto2CS () (at Assets/Editor/Proto2CsEditor/Proto2CSEditor.cs:18)
主要看這行
Rethrow as Exception: dir: /Users/luwenyi/Work/GitHub/Unity/ET_Base/ET/Proto/, command: dotnet Proto2CS.dll
因為Unity不能直接調用終端 是以需要我們手動來跳轉到對應目錄 并且執行dotnet Proto2CS.dll指令
我們建立一個名字為Proto2CS.command的檔案 在裡面輸入:(cd 你工程目錄下的ET/Proto檔案夾)
#! /bin/bash
cd /Users/luwenyi/Work/GitHub/Unity/ET_Base/ET/Proto
dotnet Proto2CS.dll
儲存好檔案之後輕按兩下執行,看到下面的輸出 就說明你做對了
好了 我們能成功生成Protocol Buffer協定了 我們下一步就來試試自己寫和伺服器的通訊吧