|
|
|
@ -1,7 +1,198 @@
@@ -1,7 +1,198 @@
|
|
|
|
|
# Godot服务端安装部署,适用于Ubuntu等Linux系统 |
|
|
|
|
# Godot Linux服务端安装部署 |
|
|
|
|
|
|
|
|
|
## 1.下载Godot |
|
|
|
|
本文档参考自 |
|
|
|
|
|
|
|
|
|
[为专用服务器导出 — Godot Engine (3.5) 简体中文文档](https://docs.godotengine.org/zh-cn/3.5/tutorials/export/exporting_for_dedicated_servers.html) |
|
|
|
|
|
|
|
|
|
# 说明 |
|
|
|
|
|
|
|
|
|
下面为编写说明,如果想直接看正文请跳转至#1.下载Godot-linux-server |
|
|
|
|
|
|
|
|
|
本文档只适用于Godot3.5.3lts 或者其他基于Godot3.5的项目。 |
|
|
|
|
|
|
|
|
|
最新的4.x没有linuxServer版本,官网给出的解释是无需linuxServer,只需要在后面加入--headless附加项,即可通过服务方式运行。 |
|
|
|
|
|
|
|
|
|
原文如下: |
|
|
|
|
|
|
|
|
|
Since Godot 4.0, this can be done by running a Godot binary on any platform with the `--headless` command line argument, or running a project exported as dedicated server. |
|
|
|
|
|
|
|
|
|
详细可以参考以下文档 |
|
|
|
|
|
|
|
|
|
[为专用服务器导出 — Godot Engine (4.x) 简体中文文档](https://docs.godotengine.org/zh-cn/4.x/tutorials/export/exporting_for_dedicated_servers.html) |
|
|
|
|
|
|
|
|
|
Godot 支持x86_64架构的导出,装有界面的Linux可以双击对应二进制文件运行,但设备需支持OpenGL ES2&OpenGL ES3。本部署文档教程只适用于无界面的服务器版本,且服务器架构为x86,armv8架构的服务器暂时还在测试中。 |
|
|
|
|
|
|
|
|
|
# 1.下载安装Godot-linux-server |
|
|
|
|
|
|
|
|
|
下载地址 |
|
|
|
|
|
|
|
|
|
[Download for Linux Server - Godot Engine](https://godotengine.org/download/3.x/server/) |
|
|
|
|
|
|
|
|
|
目前需要下载三个文件,一个是Headless(用于打包项目工程pck),一个是Standard(用于运行打包后的pck),如果需要.net支持一定要下.net版本,跟ExportTemplate(打包模板,没有配置这个打出来的包不能运行)同样也分普通版本跟支持.net的版本 |
|
|
|
|
|
|
|
|
|
Linux下载命令可以参考如下,本命令下载自3.5.3lts Mono(具备.net支持),如果下载其他版本请更换地址 |
|
|
|
|
|
|
|
|
|
```shell |
|
|
|
|
cd ~ |
|
|
|
|
# 下载Standard |
|
|
|
|
wget https://github.com/godotengine/godot/releases/download/3.5.3-stable/Godot_v3.5.3-stable_mono_linux_server_64.zip |
|
|
|
|
# 下载Headless |
|
|
|
|
wget https://github.com/godotengine/godot/releases/download/3.5.3-stable/Godot_v3.5.3-stable_mono_linux_headless_64.zip |
|
|
|
|
# 下载打包模板 |
|
|
|
|
wget https://github.com/godotengine/godot/releases/download/3.5.3-stable/Godot_v3.5.3-stable_mono_export_templates.tpz |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
以上下载可能因为网络问题下载速度慢或者下载不了,还请自备梯子。或者其他地方下载完直接拷贝到~目录下也可。 |
|
|
|
|
|
|
|
|
|
## 1.1 安装Headless |
|
|
|
|
|
|
|
|
|
下载结束后,解压Headless对应的文件到 .godot 文件夹下。 |
|
|
|
|
|
|
|
|
|
```shell |
|
|
|
|
cd ~ |
|
|
|
|
# 添加操作权限 |
|
|
|
|
sudo chmod 777 Godot_v3.5.3-stable_mono_linux_headless_64.zip |
|
|
|
|
# 解压安装包 |
|
|
|
|
unzip Godot_v3.5.3-stable_mono_linux_headless_64.zip |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
修改程序名称,并添加相关环境变量(改名跟环境变量为可选项,否则每次运行必须到该目录下运行对应二进制文件,这里为了方便操作添加)。 |
|
|
|
|
|
|
|
|
|
```shell |
|
|
|
|
# 更改文件夹名称与运行包名称 |
|
|
|
|
mv Godot_v3.5.3-stable_mono_linux_headless_64 .godot |
|
|
|
|
cd .godot/ |
|
|
|
|
mv Godot_v3.5.3-stable_mono_linux_headless.64 godot |
|
|
|
|
|
|
|
|
|
# 测试是否成功可以执行下面是否能输出版本号 |
|
|
|
|
./godot --version |
|
|
|
|
|
|
|
|
|
# 输出当前目录 |
|
|
|
|
echo $(pwd) |
|
|
|
|
# 添加环境变量,此处GODOT_ROOT为godot解压后的目录,可能有所不同 |
|
|
|
|
# 如有不同,将上述输出的目录填入即可 |
|
|
|
|
export GODOT_ROOT=/home/ubuntu/.godot |
|
|
|
|
export PATH=$PATH:$GODOT_ROOT |
|
|
|
|
|
|
|
|
|
#测试环境变量是否生效 |
|
|
|
|
godot --version |
|
|
|
|
godot --help |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
可以使用vim将上述 export 添加到 .bashrc(方便服务器重启仍然生效),此处暂不赘述。 |
|
|
|
|
|
|
|
|
|
安装结束卸载zip压缩包 |
|
|
|
|
|
|
|
|
|
```shell |
|
|
|
|
rm Godot_v3.5.3-stable_mono_linux_headless_64.zip |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
## 1.2安装打包模板 |
|
|
|
|
|
|
|
|
|
进入到godot模板路径~/.local/share/godot/templates下,如果没有该目录,可以先运行一下godot |
|
|
|
|
|
|
|
|
|
```shell |
|
|
|
|
godot |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
执行完按Ctrl+C退出 |
|
|
|
|
|
|
|
|
|
```shell |
|
|
|
|
cd ~/.local/share/godot/templates |
|
|
|
|
# 移动打包模板到该目录下,并把后缀名改为zip |
|
|
|
|
mv ~/Godot_v3.5.3-stable_mono_export_templates.tpz Godot_v3.5.3-stable_mono_export_templates.zip |
|
|
|
|
# 解压该打包模板 |
|
|
|
|
unzip Godot_v3.5.3-stable_mono_export_templates.zip |
|
|
|
|
# 解压后的文件名改名为 Godot_v3.5.3-stable_mono |
|
|
|
|
mv templates Godot_v3.5.3-stable_mono |
|
|
|
|
# 删除压缩文件 |
|
|
|
|
rm Godot_v3.5.3-stable_mono_export_templates.zip |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
如果执行到此没有任何错误,恭喜您,已经完成了godot打包环境的安装! |
|
|
|
|
|
|
|
|
|
# 2.打包工程目录 |
|
|
|
|
|
|
|
|
|
## 2.1工程准备 |
|
|
|
|
|
|
|
|
|
如果你有 现成的Godot工程,这里可以跳过直接查看 #2.2打包PCK |
|
|
|
|
|
|
|
|
|
新建一个工程起名为TestServer |
|
|
|
|
|
|
|
|
|
![](./Image/server_1.jpg) |
|
|
|
|
|
|
|
|
|
右键目录,NewScene,创建一个MainScene |
|
|
|
|
|
|
|
|
|
![](./Image/server_2.jpg) |
|
|
|
|
|
|
|
|
|
点击OtherNode,选择Node命好名,Ctrl+S保存 |
|
|
|
|
|
|
|
|
|
![](./Image/server_3.jpg) |
|
|
|
|
|
|
|
|
|
创建个脚本HelloWorld.cs,将下面代码粘贴进去 |
|
|
|
|
|
|
|
|
|
```csharp |
|
|
|
|
using Godot; |
|
|
|
|
using static Godot.GD; |
|
|
|
|
using System; |
|
|
|
|
|
|
|
|
|
public class HelloWorld : Node |
|
|
|
|
{ |
|
|
|
|
public override void _Ready() |
|
|
|
|
{ |
|
|
|
|
Print("Hello World!"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
右键场景设为主场景 |
|
|
|
|
|
|
|
|
|
![](./Image/server_4.jpg) |
|
|
|
|
|
|
|
|
|
拖拽脚本至Node上面,按下Ctrl+S保存,可以点一下Build然后运行看看是否输出Hello World! |
|
|
|
|
|
|
|
|
|
![](./Image/server_5.png) |
|
|
|
|
|
|
|
|
|
## 2.2打包PCK |
|
|
|
|
|
|
|
|
|
拷贝整个工程至服务器端,如果有使用git,可以上传该项目到git服务端或者github上,用git完成拉取 |
|
|
|
|
|
|
|
|
|
创建工程存放目录,上传到该目录并解压 |
|
|
|
|
|
|
|
|
|
```shell |
|
|
|
|
创建工程存放目录 |
|
|
|
|
cd ~ |
|
|
|
|
mkdir Project |
|
|
|
|
cd ~/Project |
|
|
|
|
# 创建构建目录 |
|
|
|
|
mkdir Build |
|
|
|
|
mkdir Build/TestServer |
|
|
|
|
# 创建工程存放目录 |
|
|
|
|
mkdir Godot |
|
|
|
|
cd Godot |
|
|
|
|
# 压缩文件上传此处略过 |
|
|
|
|
|
|
|
|
|
# 解压工程文件 |
|
|
|
|
unzip -d TestServer TestServer.zip |
|
|
|
|
# 删除压缩包 |
|
|
|
|
rm TestServer.zip |
|
|
|
|
# 进入工程目录 |
|
|
|
|
cd TestServer |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
上述工程目录进入后,我们需要一个打包预设,否则会提示 |
|
|
|
|
|
|
|
|
|
ERROR: This project doesn't have an `export_presets.cfg` file at its root. |
|
|
|
|
|
|
|
|
|
可以通过 Project > Export 来定义一个预设,打开窗口后点击Add,选择Linux/X11,可在工程下生成一个名为export_presents.cfg的文件 |
|
|
|
|
|
|
|
|
|
将该文件拷贝至工程目录下即可 |
|
|
|
|
|
|
|
|
|
接下来可以使用下面的godot命令进行打包pck了,我们指定输出目录为 ~/Project/Build/TestServer |
|
|
|
|
|
|
|
|
|
```shell |
|
|
|
|
godot --export-pack "Linux/X11" ~/Project/Build/TestServer/TestServer.pck |
|
|
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|