Fixed cross compilation from Linux #634
Open
+10
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Example: build happens from Linux CI server, with another platform, like WebGL or Mac as target. CesiumForUnity package is installed.
The build happens by means of the Unity Editor. When the editor is opened, it does two things:
Cesium can't be compiled on Linux: the native runtime is missing for Linux, and Reinterop does not generate any Linux specific code. However, when loading the Unity Editor on Linux, it tries to compile Cesium scripts for Linux, which fail because of missing Reinterop bindings. When that fails, the cross compilation to WebGL does not start at all.
Cesium .asmdef files don't declare explicit support for Linux, which is ok. However, they declare support for "Editor", which also matches the Editor on Linux. With this commit, we ensure that Cesium scripts won't be loaded for the Editor on Linux either. This way, projects can be loaded on Linux and can be built successfully for another target platform.
There is one final problem with this approach, though: when Cesium scripts are not loaded on Linux, Cesium components added the the scene will lose their data in the Editor. These components won't be there when the project is built with another target. This should not be a problem if the Cesium components will be added to the scene at runtime. A more proper fix would probably involve to make Reinterop compilation work on Linux (with stub implementations even if Cesium native is not available for Linux).
Author checklist
CHANGES.mdwith a short summary of my change (for user-facing changes).Remaining Tasks
Testing plan