I modified the source code of Cesium for Unity, packaging it into an EXE, it won't run.

I modified the source code of Cesium for Unity, but after importing it into Unity and packaging it into an EXE, it won’t run。

Here are my operation steps:I modified the multi-camera map viewing function in the source code according to the tutorial, then packaged it into a DLL and imported it into Unity. Everything worked normally in the editor. However, when I tried to package it into an EXE, the program failed to load the terrain. By checking the player.log file, I found the following error:

NotImplementedException: The native library is out of sync with the managed one.at Reinterop.ReinteropInitializer..cctor () [0x05891] in <020539f34c064d17a3bc677332842112>:0Rethrow as TypeInitializationException: The type initializer for ‘Reinterop.ReinteropInitializer’ threw an exception.at CesiumForUnity.CesiumGeoreference.CreateImplementation () [0x00000] in <020539f34c064d17a3bc677332842112>:0at CesiumForUnity.CesiumGeoreference..ctor () [0x00072] in <020539f34c064d17a3bc677332842112>:0

This is the final step that has been giving me trouble in the project, and I would greatly appreciate it if someone could offer me a helping hand.

here is another error when building:

An error occurred while building CesiumForUnityNative. See E:\com.pagis.unity@1.0.8\native~\build-Standalone\build.log for details. The command-line was:
cmake -B E:\com.pagis.unity@1.0.8\native~\build-Standalone -S E:\com.pagis.unity@1.0.8\native~ -DEDITOR=false -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=“E:\com.pagis.unity@1.0.8\Plugins\Standalone” -DREINTEROP_GENERATED_DIRECTORY=generated-Standalone

CMake Error: The source directory “E:/com.pagis.unity@1.0.8/native~” does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

Error: could not load cache

Hi @capboyji, welcome to the community!

If you want to modify Cesium for Unity - especially the native code - it’s essential you follow the Developer Setup instructions. If you’ve done that, and you’re still running into trouble, please share some more details. In particular, what platform you’re on, what platform you’re targeting with the player build, and what steps you’ve performed to build the native code for that platform.

Thank you, sir. Now let me explain the details.

Before I joined the project, the team had encapsulated some functions based on Cesium for unity 1.0.8 on windows x64. No core functionalities were modified; the work was limited to custom encapsulation of the original features, which were then repackaged into a Unity Package. After I joined, the project required me to add new functionalities, including the capability to observe the Earth with multiple cameras simultaneously.

So I downloaded the source code version of Cesium, successfully compiled it according to the tutorials, modified the C++ source code, and regenerated the dynamic library files (CesiumForUnityNative-Editor.dll and CesiumForUnityNative-Runtime.dll). As I mentioned earlier, although our project had undergone a certain degree of encapsulation, the source code remained unmodified. Therefore, I directly replaced the dynamic libraries in the original project, including the files in the Plugins folder and Editor/x86_64. Everything worked normally when I returned to Unity. After that, I spent one or two months modifying other required functionalities for the project without making any further changes to the source code. However, when I finally packaged the demo into an executable file, the error mentioned above occurred.

Hi @capboyji,

I can’t help much with the packing problems, but I wanted to suggest upgrading to the latest version of Cesium for Unity. Our latest version is v1.18.1, and we supported multiple cameras through the CesiumCameraManager as of v1.13.0. So it may be easier to make a fresh clone of main, try out the new version features, then re-add your changes as needed. If you run into anything else, we’ll at least be more able to help since you’d be working with a later version. :smiley:

Thank you, ma’am. I’ll give it a try, hope everything works out this time.

Although my team asked me to take on other tasks during the process, after overcoming so many setbacks, we finally solved this problem. Thank you all for your help—wish you a wonderful day!

1 Like