Hello Kevin,
We are facing some issues with building cesium for unity as per the developer-setup.md of cesium-unity.
I have followed all the steps but when I build the project, it builds but I get error too regarding cmake command line.
I am seeing Runtime Error on vision OS [The native implementation is missing so Update cannot be invoked. This may be caused by a missing call to CreateImplementation in one of your constructors, or it may be that the entire native implementation shared library is missing or out of date.].
Please post to the forum instead of sending me a private message. I don’t see anything sensitive in here that can’t be posted publicly.
At a glance, it sounds like your problem might be that cmake is either not installed or it can’t be found. The Cesium for Unity build process requires it to either be in the path (and I understand that the Unity application’s path will generally not match the path you have on the command-line on macOS, unlike other platforms), or it will look for it in /Applications/CMake.app/Contents/bin/cmake. You can change this by editing this file:
Sure I will post this on the forum instead of here.
Thank you for the advice, we are now not getting file not found issue, but we are getting
An error occurred while building CesiumForUnityNative. See /Users/karanmistry/Documents/GitHub/Sentinel/Packages/com.cesium.unity/native~/build-VisionOS/build.log for details. The command-line was:
/Applications/CMake.app/Contents/bin/cmake --build “/Users/karanmistry/Documents/GitHub/Sentinel/Packages/com.cesium.unity/native~/build-VisionOS” --config RelWithDebInfo --parallel 17 --target install
I am uploading the build.log here
fatal error: ‘DotNet/CesiumForUnity/Cesium3DTileset.h’ file not found #include <DotNet/CesiumForUnity/Cesium3DTileset.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I have run the command dotnet publish Reinterop~ -o . while unity is running, updated runtime script to refresh compiling and also restarted unity as you have suggested in some other forum post.
If that file is missing, it means that Reinterop has not run inside the C# compiler in Unity the way it’s supposed to. The most common cause of this is opening the project in Unity before you run dotnet publish Reinterop~ -o .. If you do that, Unity (rather obnoxiously) deletes the .meta file that tells Unity how it’s supposed to use Reinterop. So then even once you build it, Unity won’t use it properly.
The solution is to make sure that you have this file and that its content is correct:
Then let Unity compile the plugin code again, and it should generate the C++ files.
The other possibility is that Reinterop is running and generating the files, but not putting them where the C++ build expects to find them. Vision Pro isn’t a supported platform, so that wouldn’t be too surprising. You’ll need to change the paths at the top of ConfigureReinterop.cs (there are two files with this name) and/or the paths in CMakeLists.txt.
Now I no longer get the compile error. everything got built without any issues.
But (Drumroll)…
In the xcode logs I am getting these continously:
NotImplementedException: The native implementation is missing so Update cannot be invoked. This may be caused by a missing call to CreateImplementation in one of your constructors, or it may be that the entire native implementation shared library is missing or out of date.
at CesiumForUnity.Cesium3DTileset.Update () [0x00000] in <00000000000000000000000000000000>:0
That indicates the native code couldn’t be loaded. Why? Hard to say. It could be missing entirely. It could have the wrong flags set so it’s not copied to the device. It could be failing to load on the device for some reason.
I appreciate you working on this and being willing to contribute it back. But it may not be entirely straightforward, and if you run into difficulties I may not be able to help you work through them remotely like this. But let’s try!
I think my comment about “flags” is the most likely thing to check first. This source file manages compilation of the native code and also sets the properties of the produced binaries so that Unity knows what to do with them:
There’s nothing in there to handle Vision Pro yet, so that has to change. Copying the iOS bits should be a good start, but I’m not sure what else might be needed.
Those lines flag the imported asset (the built binary) as being compatible with a particular platform. Looking at it now, it’s already pretty generic, so I don’t think that part will need changes specifically. It’s just a matter of making sure it gets called for the Vision Pro build. And doing that might be as simple as adding handling for VisionPro here:
DllNotFoundException: Unable to load DLL 'CesiumForUnityNative-Runtime'. Tried the load the following dynamic libraries: Unable to load dynamic library '/CesiumForUnityNative-Runtime' because of 'Failed to open the requested dynamic library (0x06000000) dlerror() = dlopen(/CesiumForUnityNative-Runtime, 0x0005): tried: '/CesiumForUnityNative-Runtime' (no such file)
at Reinterop.ReinteropInitializer..cctor () [0x00000] in <00000000000000000000000000000000>:0
at CesiumForUnity.CesiumGeoreference.CreateImplementation () [0x00000] in <00000000000000000000000000000000>:0
Rethrow as TypeInitializationException: The type initializer for 'Reinterop.ReinteropInitializer' threw an exception.
at CesiumForUnity.CesiumGeoreference.CreateImplementation () [0x00000] in <00000000000000000000000000000000>:0
NotImplementedException: The native implementation is missing so Update cannot be invoked. This may be caused by a missing call to CreateImplementation in one of your constructors, or it may be that the entire native implementation shared library is missing or out of date.
at CesiumForUnity.Cesium3DTileset.Update () [0x00000] in <00000000000000000000000000000000>:0
Hi @Analog, I’m not sure where to tell you to go from here. The symbols that are undefined in your latest screenshots should be coming from libCesiumGltf.a and friends. Since you appear to have them, and they are set to target VisionOS, I’m not sure what’s going wrong.
I’d start by looking earlier in the log for a message about being unload to load a library file of some sort. For example, if the library were being compiled for the wrong platform or CPU, that could cause the sort of problem you’re seeing. You may be able to make some progress in understanding by looking closely at the xcode project. Are those libraries included in the link line?
Yes @Kevin_Ring , I think the Packages/com.cesium.unity/native~/build-visionOS-arm64/CesiumForUnityNative.xcodeproj is still getting build for iOS, it would help to know where to refactor to get this to build for visionOS. I have changed all the UNITY_IOS to UNITY_VISIONOS but still might have missed something. Let me know what to change to make native build for visionOS.
Ok so you’ve copied this code and modified it for Vision OS, right?
Changing that -DCMAKE_SYSTEM_NAME=iOS to … whatever the right thing is for Vision OS should do the trick. Well, CMake needs to know what this means, too. If you look at the docs for that variable, you can see visionOS listed. But that was presumably added in a very recent version of CMake. Looks like 3.28 to be specific: https://cmake.org/cmake/help/latest/release/3.28.html
So as long as you have that -DCMAKE_SYSTEM_NAME=visionOS, and you have a new enough version of CMake, and the build is finishing without errors, I suspect you’re ok on that front.
Then the next thing is to confirm that the binaries produced in that build are correctly flagged for VisionOS within Unity. The easiest way to do that is to navigate to them in the Content folder in Unity and see what their properties look like. Share a screenshot if you’re not sure.
So as long as you have that -DCMAKE_SYSTEM_NAME=visionOS , and you have a new enough version of CMake, and the build is finishing without errors, I suspect you’re ok on that front.
Then the next thing is to confirm that the binaries produced in that build are correctly flagged for VisionOS within Unity. The easiest way to do that is to navigate to them in the Content folder in Unity and see what their properties look like. Share a screenshot if you’re not sure.
Not sure what binaries you are talking about. Where in content folder?
You mean Assets/… or Packages/com.cesium.unity/…