I’m having problems trying to compile the project targeting the tvOS platform.
I think it’s not an issue with my project integrating the package, because opening the the Unity samples for v1.19.0 with Unity 6 targeting tvOS has the same compilation errors:
Library/PackageCache/com.cesium.unity@03780efe4504/Runtime/CesiumPointCloudRenderer.cs(101,17): error CS0103: The name 'XRSettings' does not exist in the current context
Library/PackageCache/com.cesium.unity@03780efe4504/Runtime/CesiumPointCloudRenderer.cs(101,51): error CS0103: The name 'XRSettings' does not exist in the current context
Library/PackageCache/com.cesium.unity@03780efe4504/Runtime/CesiumPointCloudRenderer.cs(102,17): error CS0103: The name 'XRSettings' does not exist in the current context
Library/PackageCache/com.cesium.unity@03780efe4504/Runtime/CesiumPointCloudRenderer.cs(102,51): error CS0103: The name 'XRSettings' does not exist in the current context
I’ve tried removing all XR and VR packages (because we don’t need them) and the problem persists.
I’ve also created a bug in the GitHub page with the same issue.
I just found out that if I add in PlayerSetting only for tvOS in the Scripting Define Symbols the define ENABLE_XR the compilation errors disappear, but a new one appear:
Library/PackageCache/com.unity.test-framework@1f954279c37e/UnityEditor.TestRunner/UnityTestProtocol/UtpMessageBuilder.cs(49,47): error CS0117: ‘XRDevice’ does not contain a definition for ‘model’
Ok, one way to fix this is to modify the package to fix this class for tvOS. Basically in the class that is throwing the error CesiumPointCloudRenderer, add a #if_def in the part that is causing the error:
tvOS is not a supported platform, and as far as I know you’re the first person to try it.
I think that even if you get past these XR issues, you’ll also need to build the native code for the tvOS platform. This is usually the much more challenging part of supporting a new platform. To start, you’ll need to follow the Developer Setup instructions. Changes to the plugin will certainly be required. But if you get it working, we’re happy to accept a pull request for it, and then your changes will be included in the next release!
Can you please walk us through the steps that lead to the problem you’re seeing? If you believe you have a fix, please open a pull request with it and we’ll take a look!
The XR related symbols can’t be accessed unless the Unity package “com.unity.xr.management” is installed in the Unity project. I see that the package is there by default for some template projects (I verified the URP template). But our Unity project does not have that package installed for some reason. It might have been explicitly uninstalled because it is not really needed for us.
When that package is missing, we get the following error for CesiumForUnity package compilation:
Library/PackageCache/com.cesium.unity@03780efe4504/Runtime/CesiumPointCloudRenderer.cs(101,17): error CS0103: The name ‘XRSettings’ does not exist in the current context
It can be fixed by adding ENABLE_XR_MODULE checks around the according code:
However even after your fix I am not able to compile our project for tvOS platform with error message: The type or namespace name ‘CesiumForUnity’ could not be found. Any idea what can be wrong? Others platforms OK, same for Editor.
It is maybe the lack of support of tvOS, @Kevin_Ring is not by any chance tvOS support on your roadmap? Thx
tvOS is not a supported platform, so the native code binaries for that platform are missing. You’ll need to make modifications to the plugin to support that platform, and build it yourself.
I have manage to open the examples in the editor using tvOS as the target platform (I had to fix some errors on the sample code to be able to compile for this platform).
But I’m stuck trying to compile the native library for tvOS. I have very little knowledge of CMake so I’m doing my best to make it work.
One of the errors that I found out, was that it was not detecting correctly the triplets, so I change that to use arm64-tvos but got other errors.
Can you please guide me a little bit to know what I’m missing or what can I do to make it work?
Hi again, I’ve made some progress and after many tries I “manage” to compile the cesium native library for tvOS. I haven’t try on a real device jet… that’s the second part.
One of the problemas that I found is that the blend2d and asmjit library should not be included for iOS and also for tvOS. That is indicated inside the cesium native repo, inside Packages/com.cesium.unity/native~/extern/cesium-native/CMakeLists.txt and also Packages/com.cesium.unity/native~/extern/cesium-native/CesiumVectorData/CMakeLists.txt
there is this condition:
# asmjit needed by blend2d on non-iOS platforms (iOS and Wasm don't support JIT)
if(NOT CESIUM_TARGET_WASM AND NOT IOS AND NOT VCPKG_CMAKE_SYSTEM_NAME MATCHES "iOS")
list(APPEND PACKAGES_PRIVATE blend2d asmjit)
else()
# Use [core] feature to disable default jit feature.
list(APPEND PACKAGES_PRIVATE blend2d[core])
endif()
But I don’t know what condition to add to check for tvOS, what I did is this:
# asmjit needed by blend2d on non-iOS platforms (iOS and Wasm don't support JIT)
if(NOT CESIUM_TARGET_WASM AND NOT IOS AND NOT VCPKG_CMAKE_SYSTEM_NAME MATCHES "iOS" AND NOT TVOS AND NOT VCPKG_CMAKE_SYSTEM_NAME MATCHES "tvOS")
list(APPEND PACKAGES_PRIVATE blend2d asmjit)
else()
# Use [core] feature to disable default jit feature.
list(APPEND PACKAGES_PRIVATE blend2d[core])
endif()
But that didn’t work. @Kevin_Ring Do you know what condition should I add to check for tvOS?
That check of VCPKG_CMAKE_SYSTEM_NAME is a little bit suspicious, because I’m not sure it will be set in this context. CMAKE_SYSTEM_NAME, however, should be. So try checking CMAKE_SYSTEM_NAME MATCHES "tvOS". I verified that tvOS is the correct string by looking here:
Unfortunately, CMake doesn’t have an equivalent of the IOS variable for tvOS so we can’t just do NOT TVOS.
Thanks for the response. With the variable CMAKE_SYSTEM_NAME did work, and was able to compile the sample project for tvOS.
Now I wanted to test it on our own project, so I wanted to create the package, and for that I followed the instructions from here.
It did end and created the .tar.gz package, but when I used it in our own project and try to make a tvOS build, I get a lot of compile errors related with Reinterop. For example:
Packages/com.cesium.unity/Source/Runtime/Cesium3DTile.cs(2,7): error CS0246: The type or namespace name 'Reinterop' could not be found (are you missing a using directive or an assembly reference?)
Do you know what could be the reason? Am I missing a step?
Finally we manage to compile and create the package also for tvOS. We tested on a real device and for our simple test scenario it works fine!
We wanted to upload this changes, but now the question is, if there is some procedure to create the pull requests? Because the changes are in both projects, the unity package and also the native library.
Hi @Fengel, great to hear you got it working! We’d definitely appreciate a pull request.
If you changed both cesium-native and cesium-unity, you’ll need to open two pull requests. The cesium-unity one should have the native~/extern/cesium-native submodule updated to point to the same commit as the cesium-native PR.