Deepin系统下基于Visual Studio Code的Unity开发环境配置

适用操作系统

  • Deepin
  • UOS
  • Ubuntu
  • Debian

Unity安装

1. 通过官方网站下载Unity Hub .deb安装文件

下载地址: https://unity.cn/releases

2. 通过添加Unity Hub repository,使用APT包管理安装

参考地址:https://docs.unity3d.com/hub/manual/InstallHub.html

安装:依次执行以下命令

1
2
3
4
sudo sh -c 'echo "deb https://hub.unity3d.com/linux/repos/deb stable main" > /etc/apt/sources.list.d/unityhub.list'
wget -qO - https://hub.unity3d.com/linux/keys/public | sudo apt-key add -
sudo apt update
sudo apt-get install unityhub

卸载:

1
sudo apt-get remove unityhub

Visual Studio Code安装

1. Visual Studio Code本体安装

2. Visual Studio Code插件安装

  • C#
  • C# XML Documentation Comments
  • Debugger for Unity
  • IntelliCode
  • Todo Tree

.Net Core SDK安装

官方参考文档:https://docs.microsoft.com/zh-cn/dotnet/core/install/linux-debian

使用APT包管理安装

打开终端并运行以下命令:用于添加签名密钥

1
2
3
wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb

安装SDK:

1
2
sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-6.0

使用SNAP安装

打开终端执行如下命令:

1
2
sudo snap install dotnet-sdk --classic --channel=7.0
sudo snap alias dotnet-sdk.dotnet dotnet

配置环境变量 :

1
export DOTNET_ROOT=/snap/dotnet-sdk/current

以上命令只在执行的当前shell生效,将以上命令添加到系统shell的配置文件中使其永久生效,相关Shell的配置文件路径如下:

  • Bash Shell:/.bash_profile、/.bashrc
  • Korn Shell:~/.kshrc 或 .profile
  • Z Shell:~/.zshrc 或 .zprofile

安装Mono

参考地址:https://www.mono-project.com/download/stable/#download-lin-debian

打开终端执行如下命令:

1
2
3
4
5
sudo apt install apt-transport-https dirmngr gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/debian stable-buster main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update
sudo apt install mono-devel

验证Mono是否安装成功,可参考文档:https://www.mono-project.com/docs/getting-started/mono-basics/

配置OmniSharp

  • 打开Visual Studio Code的配置
  • 搜索 Use Modern Net ,取消勾选

为Unity配置C#代码编辑器

在菜单栏 Editor>ReferencesExternal Tool 中,external script editor 选择 Visual Studio Code,如果没有Visual Studio Code选项,则选择Browser,到 usr>bin 目录下选择Visual Studio Code的可选择文件。

external script editor args 中出现了完整的参数列表,表示配置成功。

安装Plastic scm Cloud

参考文档:https://www.plasticscm.com/plastic-for-linux

终端依次执⾏如下命令:

1
2
3
4
5
6
7
8
sudo apt-get update
sudo apt-get install -y apt-transport-https
echo "deb https://www.plasticscm.com/plasticrepo/stable/debian/ ./" | 
sudo tee /etc/apt/sources.list.d/plasticscm-stable.list
wget https://www.plasticscm.com/plasticrepo/stable/debian/Release.key -O - | 
sudo apt-key add -
sudo apt-get update
sudo apt-get install plasticscm-cloud

如果提示 有未满足的依赖关系:
/etc/apt/sources.list.d ⽬录下新建名为:bionic-oldlibs.list 的⽂件,并在⽂件中添加如下两⾏命令(需要使⽤管理员身份打开⽬录才能创建⽂件):

1
2
deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
deb http://us.archive.ubuntu.com/ubuntu/ bionic universe

然后终端执⾏:

1
2
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32
sudo apt update

再次执⾏最开始命令:

1
2
3
4
5
6
7
sudo apt-get update
sudo apt-get install -y apt-transport-https
echo "deb https://www.plasticscm.com/plasticrepo/stable/debian/ ./" | 
sudo tee /etc/apt/sources.list.d/plasticscm-stable.list
wget https://www.plasticscm.com/plasticrepo/stable/debian/Release.key -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get install plasticscm-cloud