系列索引:UE入门教程索引
按照UE入门教程05:安装与配置安装配置UE4
按照Vistual Studio Community 2022安装与配置安装配置VS2022,注意你需要选择使用C++的桌面开发
、.NET桌面开发
、Windows 10 SDK 10.0.19041
组件

打开命令行工具


下载源码
1 2 3 4 5 6 7 8 9 10 11
| git clone https://github.com/Microsoft/AirSim.git
PS D:\> git clone https://github.com/Microsoft/AirSim.git Cloning into 'AirSim'... remote: Enumerating objects: 41981, done. remote: Total 41981 (delta 0), reused 0 (delta 0), pack-reused 41981 Receiving objects: 100% (41981/41981), 367.50 MiB | Receiving objects: 100% (41981/41981), 367.72 MiB | 1.40 MiB/s, done.
Resolving deltas: 100% (26913/26913), done. Updating files: 100% (1427/1427), done.
|
转到源码目录
运行编译命令

脚本会自动调用VS2022编译源码

编译完成时会自动生成工程

工程生成就表示编译成功完成,一些目录没有不用管

打开目录AirSim\Unreal\Environment\Blocks

双击打开Blocks.uproject
,UE会自动调用VS编译

打开sln工程

选择配置DebugGame Editor + Win64

设置Blocks为启动项

点击F5
编译运行


自动运行UE

点击运行
,会提示是选择汽车还是四旋翼飞机(只选择一次)

选择飞机

至此,AirSim配置完成
测试
修改位于~/Documents/AirSim/settings.json
的配置文件

清理
使用命令
清理所有相关文件,恢复刚下载的状态。
问题
问题1
命令行编译AirSim报错
1 2 3 4 5 6 7
| D:\AirSim\Unreal\Environments\Blocks>powershell -command "& { (Get-ItemProperty 'Registry::HKEY_CLASSES_ROOT\Unreal.ProjectFile\shell\rungenproj' -Name 'Icon' ).'Icon' } > gen_temp.tmp" Get-ItemProperty : 找不到路径“HKEY_CLASSES_ROOT\Unreal.ProjectFile\shell\rungenproj”,因为该路径不存在。 所在位置 行:1 字符: 6 + & { (Get-ItemProperty 'Registry::HKEY_CLASSES_ROOT\Unreal.ProjectFile ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (HKEY_CLASSES_RO...hell\rungenproj:String) [Get-ItemProperty], ItemNotFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetItemPropertyCommand
|
退出UE然后重新打开

点击修复即可
问题2
VS2022编译报错
1 2 3
| 1> AirLib.lib(FileSystem.obj) : 找到 MSIL .netmodule 或使用 /GL 编译的模块;正在使用 /LTCG 重新启动链接;将 /LTCG 添加到链接命令行以改进链接器性能 1>EXEC : fatal error C1900: “P1”(第“20221215”版)和“P2”(第“20210202”版)之间 Il 不匹配 1>LINK : fatal error LNK1257: 代码生成失败
|
使用VS2022,但是调用的库和VS2022的库版本不同,问题应该是同时安装了VS2019和VS2022
打开UE,随便新建一个工程,点击 编辑-> 编辑器偏好设置 ->源代码

将版本设置为VS2022


参考资料