![]() |
Cesium for Unreal 2.21.0
|
Detailed instructions for setting up a Cesium for Unreal development environment on Windows. Please see the Developer Setup page for an overview of the process.
Desktop development with C++Game development with C++.NET Framework 4.8 SDK (or newer) c:/android not c:\android. The following illustrates the recommended directory layout for developers:
C:\Dev - Your own root directory for development. Keep it short!C:\Dev\cesium-unreal-samples - The directory for the Unreal project that will use the plugin.C:\Dev\cesium-unreal-samples\Plugins\cesium-unreal - The directory for the actual Cesium for Unreal plugin.C:\Dev\cesium-unreal-samples\Plugins\cesium-unreal\extern\cesium-native - The directory for the base libraries project.You may use any directory for the project, but the directory for the actual Cesium for Unreal plugin MUST be in a subdirectory Plugins/cesium-unreal of the project directory. This way, Unreal will automatically find the Plugin when running the project, and pick up any changes that have been made to the plugin.
This can be set up with the following sequence of commands, on the console, starting in the C:\Dev directory:
cesium-native submodule and its dependencies. If you forget the --recursive option, you will see many compiler errors later in this process. If this happens to you, run the following in the Plugins\cesium-unreal directory to update the submodules in the existing clone: The cesium-native libraries and their dependencies use CMake and must be built separately from Cesium for Unreal. There are a number of ways to do this, depending on your preferred environment:
The version of CMake included with Visual Studio 2017 is too old to build cesium-native, so to build with Visual Studio 2017, follow the CMake command-line or CMake GUI instructions.
Launch Visual Studio 2022 and "Open a local folder". Select C:\Dev\cesium-unreal-samples\Plugins\cesium-unreal\extern.
extern directory, not the cesium-native subdirectory.Find the "Solution Explorer - Folder View".
To build a "Debug" build of cesium-native,
CMakeLists.txt and select "Install".c:\Dev\cesium-unreal-samples\Plugins\cesium-unreal\Source\ThirdParty.To build a "Release" build of cesium-native,
CMakeLists.txt and select "CMake Settings for cesium-unreal-extern".+ and choose x64-Release.CMakeLists.txt again and choose "Install". Open the C:\Dev\cesium-unreal-samples\Plugins\cesium-unreal\extern folder in Visual Studio Code and invoke the "install" target.
cmake-guiC:\Dev\cesium-unreal-samples\Plugins\cesium-unreal\extern extern directory, and not the cesium-native subdirectory!C:\Dev\cesium-unreal-samples\Plugins\cesium-unreal\extern\buildThis will generate the project file called cesium-unreal-extern.sln in the directory C:\Dev\cesium-unreal-samples\Plugins\cesium-unreal\extern\build. You can open this solution file in the Visual Studio IDE and compile as normal. To install cesium-native to the project - which is required for use with Cesium for Unreal - right-click on INSTALL in Solution Explorer, and choose Build. INSTALL may be found inside a folder called CMakePredefinedTargets. Use the Solution Configuration dropdown to change between the Debug and Release configurations.
First, configure the CMake project in the C:\Dev\cesium-unreal-samples\Plugins\cesium-unreal\extern directory by following the instructions below.
extern directory, and not the cesium-native subdirectory!To configure for Visual Studio 2022, open "x64 Native Tools Command Prompt for VS 2022" and execute the following command:
With either compiler, the commands above will generate the project file called cesium-unreal-extern.sln in the directory C:\Dev\cesium-unreal-samples\Plugins\cesium-unreal\extern\build. You can open this solution file in the Visual Studio IDE and compile as normal. To install cesium-native to the project - which is required for use with Cesium for Unreal - right-click on INSTALL in Solution Explorer, and choose Build. INSTALL may be found inside a folder called CMakePredefinedTargets. Use the Solution Configuration dropdown to change between the Debug and Release configurations.
You can also build the Release version entirely from the command-line:
Or the debug version:
To cross-compile Cesium Native for Android, ensure that you have installed Android Studio and Android NDK, and configured ANDROID_NDK_ROOT. Then you will need to have Ninja installed. With chocolatey, you can run:
or download Ninja from GitHub and add it to your PATH.
Then, change into the C:\Dev\cesium-unreal-samples\Plugins\cesium-unreal\extern directory, and execute the following commands. (Note: The following steps must be done in the extern directory, and not the cesium-native subdirectory!). To create and install the Release package for Android:
You can also build and install the debug version by using Debug or RelWithDebInfo instead of Release.
The project files for the samples project, including the actual Cesium for Unreal plugin, can be created with the Unreal Engine.
\cesium-unreal-samples\Plugins\cesium-unreal\Documentation\Source folder to \cesium-unreal-samples\cesium-unreal-samples directoryCesiumForUnrealSamples.uproject fileThis will generate the CesiumForUnrealSamples.sln file that can be opened, compiled, and debugger with Visual Studio. Be sure to switch the "Solution Platform" to "Win64".
Source directory from this documentation folder into the root directory of your project. Your project should now work as a C++ project. However, you probably do not want to commit this change to your project's source code repository. A project that includes C++ code like this will require everyone opening the project to have an installed and working C++ compiler, including e.g. artists that do not typically have such an environment.If you have both Visual Studio 2017 and Visual Studio 2019 installed, the Visual Studio project files generated above may build with VS2017 even if they're opened with VS2019. This will still be true even if you allow VS2019 to upgrade the project files to the VS2019 toolchain. That's because the project files simply invoke the Unreal Build Tool, which plays by its own rules. This is generally not a problem, except if you used Visual Studio 2019 to build cesium-native. In that case, you will get linker errors when you try to compile Cesium for Unreal.
To switch the Unreal Build Tool to use VS2019 instead, launch the Unreal Editor and open a project that does not use Cesium for Unreal. Go to Edit -> Editor Preferences. Go to the General -> Source Code section and change Source Code Editor to Visual Studio 2019. Click "Set as Default" so that this change applies to all projects that don't override it.
During development, you will typically use the "DebugGame Editor" or "Development Editor" Solution Configuration in the Visual Studio solution created above. "DebugGame Editor" is easier to debug, but "Development Editor" will be a bit faster. In either case, but sure that "Win64" is selected as the Solution Platform.
When you build "DebugGame Editor", the build process will first look for an installed Debug build of cesium-native. If it finds one, it will use it. If not, it will try to use an installed Release build of cesium-native instead. The "Development Editor" configuration, on the other hand, will always use an installed Release build of cesium-native, and will fail to build if one does not exist.
So, when you make changes to cesium-native code, make sure you are building and installing the correct configuration of cesium-native for the Cesium for Unreal configuration that you're using:
Development Editor -> ReleaseDebugGame Editor -> DebugSee the sections above to learn how to build the Debug and Release configurations of cesium-native in your preferred environment.
While actively making changes to cesium-native, it is usually convenient to have two copies of Visual Studio open: one for cesium-native, and one for Cesium for Unreal.
In the Cesium for Unreal solution in Visual Studio, press F5 (or select "Debug->Start Debugging" from the menu) to start in debug mode.
Starting in debug mode makes it possible to set breakpoints, inspect variables with the debugger, or receive stack trace information in the case of crashes. For pure feature tests, it is also possible to press CTRL-F5 (or select "Debug->Start Without Debugging" from the menu) to start.
When using the "DebugGame Editor" solution configuration and the Debug configuration of cesium-native, it is also possible to debug through cesium-native code. First, make sure "Just my Code" is disabled:
Tools -> Options.Debugging -> General.Enable Just My Code is unchecked.Once that is done, it is possible to set breakpoints in Cesium for Unreal plugin code and step from there straight into cesium-native code. It's also possible to set breakpoints in cesium-native code directly, but it can be a bit of a hassle to navigate to those files because they aren't in the Cesium for Unreal solution. There are two ways to open cesium-native files from the Cesium for Unreal solution for debugging purposes:
Plugins\cesium-unreal\extern\cesium-native. Getting back to the default Solution Explorer view can be a pain. The trick is to double-click the .sln file in Folder View.File -> Open -> File, and paste in the copied file path.If you find the debugger refuses to step into cesium-native code, check that you're using the "DebugGame Editor" configuration of Cesium for Unreal and the Debug configuration of cesium-native, and that you've built and installed cesium-native.