UE4編譯專用服務(wù)器
來源:
52vr |
責(zé)任編輯:傳說的落葉 |
發(fā)布時(shí)間: 2019-06-11 08:39 | 瀏覽量:
[代碼]:
1 |
<span style= "font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);" >最近想要編譯出UE4的專用服務(wù)器,編譯成單獨(dú)的exe。研究了好幾天,網(wǎng)上找了一些方法,但是均試驗(yàn)失敗,最后發(fā)現(xiàn)要自己加xxx.cs才行!網(wǎng)上一些方法都并沒有提到這個(gè)!現(xiàn)寫下詳細(xì)過程及分析,以供各位參考!</span> |
總結(jié)出幾個(gè)要點(diǎn):
1.要下載UE4源代碼。在GITHUB上有,可以從Epic上快速找到,如下圖:
下載好以后,按順序點(diǎn)擊
1.setup.bat 點(diǎn)擊以后會(huì)下載大概4G的東西,根據(jù)網(wǎng)速不同要幾個(gè)小時(shí)吧
2.GenerateProjectFiles.bat 點(diǎn)擊以后會(huì)生成出UE4.sln
下載源碼花了我一天時(shí)間!我把源碼打包上傳到網(wǎng)盤了,想要速度比較快的,可以到我網(wǎng)盤下載
http://download.csdn.NET/detail/sukeychen/9593597
收5積分...實(shí)在沒積分的留言我可以發(fā)你們
2.打開UE4.sln,選擇解決方案配置的Development Editor,編譯出UE4編輯器
3.用這個(gè)編輯器新建的工程,就可以用來編譯Server了。但是如果你要編譯的是舊工程的Server也不用擔(dān)心,可以改版本,效果是一樣的。
右鍵點(diǎn)擊工程 選擇Switch Unreal Engine version...就可以選擇版本了:
4.在工程文件目錄下的Source文件夾下,新建VRGameServer.Target.cs文件
文件內(nèi)容類似:
[代碼]:
01 |
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved. |
02 |
|
03 |
using UnrealBuildTool; |
04 |
using System.Collections.Generic; |
05 |
|
06 |
public class GameServerTarget : TargetRules |
07 |
{ |
08 |
public GameServerTarget(TargetInfo Target) |
09 |
{ |
10 |
Type = TargetType.Server; |
11 |
} |
12 |
|
13 |
// |
14 |
// TargetRules interface. |
15 |
// |
16 |
public override void SetupBinaries( |
17 |
TargetInfo Target, |
18 |
ref List<uebuildbinaryconfiguration> OutBuildBinaryConfigurations, |
19 |
ref List< string > OutExtraModuleNames |
20 |
) |
21 |
{ |
22 |
base .SetupBinaries(Target, ref OutBuildBinaryConfigurations, ref OutExtraModuleNames); |
23 |
OutExtraModuleNames.Add( "Game" ); |
24 |
} |
25 |
|
26 |
public override bool GetSupportedPlatforms( ref List<unrealtargetplatform> OutPlatforms) |
27 |
{ |
28 |
// It is valid for only server platforms |
29 |
return UnrealBuildTool.UnrealBuildTool.GetAllServerPlatforms( ref OutPlatforms, false ); |
30 |
} |
31 |
|
32 |
public override List<unrealtargetplatform> GUBP_GetPlatforms_MonolithicOnly(UnrealTargetPlatform HostPlatform) |
33 |
{ |
34 |
if (HostPlatform == UnrealTargetPlatform.Mac) |
35 |
{ |
36 |
return new List<unrealtargetplatform>(); |
37 |
} |
38 |
return new List<unrealtargetplatform> { HostPlatform, UnrealTargetPlatform.Win32, UnrealTargetPlatform.Linux }; |
39 |
} |
40 |
|
41 |
public override List<unrealtargetconfiguration> GUBP_GetConfigs_MonolithicOnly(UnrealTargetPlatform HostPlatform, UnrealTargetPlatform Platform) |
42 |
{ |
43 |
return new List<unrealtargetconfiguration> { UnrealTargetConfiguration.Development }; |
44 |
} |
45 |
} </unrealtargetconfiguration></unrealtargetconfiguration></unrealtargetplatform></unrealtargetplatform></unrealtargetplatform></unrealtargetplatform></ string ></uebuildbinaryconfiguration> |
把
[代碼]:
1 |
GameServerTarget |
改為
[代碼]:
1 |
你項(xiàng)目名ServerTarget |
比如我的就是改成
[代碼]:
1 |
VRGameServerTarget |
把
[代碼]:
1 |
OutExtraModuleNames.Add( "Game" ); |
改為
[代碼]:
1 |
OutExtraModuleNames.Add( "項(xiàng)目名" ); |
比如我的就是改成
[代碼]:
1 |
OutExtraModuleNames.Add( "VRGame" ); |
然后在工程文件上按右鍵選擇Generate Visual Studio project files 重新生成VS文件。
5.打開工程文件的sln(我的是VRGame.sln)
選擇Development Server選項(xiàng)進(jìn)行編譯
編譯的時(shí)間會(huì)有點(diǎn)久,耐心等待=.=
(說明:如果不是用編譯版的,直接用的下載好的版本,加入xxxserver.cs以后,也是會(huì)出現(xiàn)Development Server選項(xiàng),但是會(huì)報(bào)錯(cuò),打不開頭文件,因?yàn)橄螺d版的源代碼是只能看,不能編譯和重新構(gòu)建的)
6.在工程目錄下的Binaries下的Win64里就會(huì)出現(xiàn)XXXServer.exe(XXX為你自己的工程名)
我的是:
D:\VRGame\Binaries\Win64
7.設(shè)置好默認(rèn)地圖,打包工程,據(jù)說不勾選Use pak file 和 full rebuild編譯會(huì)快些(但是我沒感覺出來有變快=.=)
8.把XXXServer.exe復(fù)制到打包好的文件下的Binaries下的Win64里
9.右鍵把XXXServer.exe設(shè)置為快捷方式,在快捷方式里按右鍵->屬性-> 在路徑后面加 -log
就能顯示出控制臺(tái)了。
10.在客戶端輸入 ~open 127.0.0.1 就可以連接上服務(wù)器了
(127.0.0.1為本機(jī),如果是在其他機(jī)子則填對(duì)應(yīng)IP)
參考網(wǎng)址:
http://www.cnblogs.com/moelocus/p/5599509.html
https://wiki.unrealengine.com/Standalone_Dedicated_Server
https://www.youtube.com/watch?v=zSA8zUo8oCg
-
分享到:
相關(guān)文章
網(wǎng)友評(píng)論
您需要登錄后才可以發(fā)帖 登錄 | 立即注冊(cè)
關(guān)閉
- 用戶名:
- 密 碼:
- 驗(yàn)證碼: 看不清? 點(diǎn)擊更換
- 忘記密碼?
全部評(píng)論:0條
推薦
熱門