How do you handle UI for cross platform AR projects (mobile, headsets)?

One of the projects I’m on is based on AR Foundation and targets iOS, Android and MagicLeap 2. The thing is that it’s mostly same codebase. The main difference is the actual rig (hand worn vs head worn), so the camera and controller stuff is set up differently but everything else is the same.

For the UI I use Canvas - which is Overlay for mobile and World Space for ML2.

The question is, how shall I organize code for my platforms so that it’s the least hassle to maintain. How generally devs support such things? A branch per platform? Git submodules? Custom scripts that alter GameObjects on platform change?

Asking to see how others approach that.

We use custom scripts on our main branch to handle platform-specific edge cases in our sample app.

For example here’s our MenuLoader script that loads a different main menu scene depending on the platform: arfoundation-samples/Assets/Scripts/Runtime/UI/MenuLoader.cs at 5.1 · Unity-Technologies/arfoundation-samples · GitHub

1 Like