Unity MARS 1.1 is now available

Read on to learn more about latest updates and features in Unity MARS, including the new Rules workflow.

Rules

At its core, augmented reality (AR) combines the digital and real world together. Unity MARS is designed to help you easily tell computers how to lay out that digital content in ways that relate to the real world. Through the use of proxies, stand-ins for real-world objects, and conditions, the criteria you set for when and how you want your digital content to interact with those real-world objects, Unity MARS will look for suitable locations in the real-world, place your digital content where it finds a good match, and trigger actions and events.

We don’t normally think about it this way, but just like in real life, we only want to put things where it makes sense for them to go. For example, if we’re standing in a kitchen, we’ll place our coffee mug on the kitchen table or countertop, rather than on the floor. In Unity MARS nomenclature, this means ‘conditions are satisfied’. With Unity MARS, you can define any set of conditions you want, and to simplify things, we call this set of conditions a Rule.

With Rules, you can now take an alternative approach to the way you define the behavior of your AR application, and review it in an intuitive way outside of the traditional parent-child hierarchy found in the Hierarchy and Inspector Windows.

Introducing a new procedural workflow: Rules

Our new Rules feature (Window > MARS > Proxy Rule Set) is specifically designed to help you reason through the procedural rules in a Unity MARS scene in an intuitive way, providing a faster way to author, and an easy starting point for new users.

We provide a new window that combines proxies, conditions, actions, and landmarks into a single view describing Rules. Information is displayed in a flow that aligns with how the developer must think about content responding to a real-time understanding of the real-world scene.

The feature allows Rules to be viewed in a logical sequence, grouping associated conditions and actions together. The underlying parent-child hierarchy still exists and accessible if the developer wishes to see it.

For a detailed walkthrough, see the new Rules documentation page.

tl;dr -

  • Define & review app behavior using natural-language rules: eg. “On every surface, spawn grass” or “On three image markers, show assets”.

  • See layout and content behavior quickly in a straightforward presentation.

API Cleanup
Along with adding the new ProxyRuleSet feature, we’ve made some major API changes in Unity MARS 1.1, including breaking changes. Normally this would require a major version bump (2.x) but because Unity MARS is so new, and because users will not have to fundamentally change how anything works in their projects, we felt that this was still in the spirit of a minor version. The biggest change was moving many less important types out of the Unity.MARS namespace into appropriate sub-namespaces.

All of your proxy objects and scenes will work just as they did before, but if you have written any code that uses Unity MARS types, you may have to do some work when you upgrade to Unity MARS 1.1. Reach out to us directly if you’d like help.

Here are some common pitfalls that users may encounter, and solutions that worked for us:

  • Always ensure that you have a backup of your project before upgrading. Make a copy of the entire folder, or make sure that you have everything you need tracked and committed in version control.

  • Some APIs have been removed or are no longer public. If any of these were useful to you, and don’t have a clear replacement, please let us know in this thread. We are happy to help.

  • Most of the API changes move types out of the main Unity MARS namespace, or otherwise clean up namespaces to make the API clearer and more consistent. The API Updater will handle most of these changes, but there are some caveats.

  • The updater solves these problems by fully-qualifying types that have moved. This may not be how you want your code to look, so you will probably want to fix that up manually.

  • In the case of extension methods like this.GetCameraScale(), which cannot be fully qualified, you will see compile errors.

  • In both of these cases, we recommend that you first try using your IDE’s “Organize Imports” functionality. It is accessed slightly differently in the various versions of Visual Studio and Rider, but they all have some sort of feature for sorting and cleaning up C# imports. We have found that applying this action to individual code files, or across the solution fixed the errors we encountered when updating our examples and test projects.

  • It is always best to delete your project Library after major updates to let it regenerate, or do an Assets > Reimport All.

  • Unity.MARS.MarsUserPreferences is now a static class rather than a ScriptableObject. If you encounter the following error, delete this file from Assets/MARS/UserSettings.
    'Unity.MARS.MarsUserPreferences' is missing the class attribute 'ExtensionOfNativeClass'!

AR Foundation Providers
In order to provide support for Unity 2020.2 and later, which do not support AR Foundation 2.x, we dropped the hard dependency on AR Foundation in our Unity MARS AR Foundation Providers package. We have updated the MARS installer so that new installations will have AR Foundation installed along with the base MARS packages. In existing projects you will need to add it to your project manifest. Either modify your manifest.json to put in the desired version, or install it normally via the Package Manager UI.

We have also implemented a wrapper for the Camera Direction feature exposed in AR Foundation 4.x which allows you to switch between front-facing camera (face tracking) and rear camera (world tracking) without reloading the scene.

For a detailed list of changes, refer to the changelogs entry for 1.1.1 in Unity MARS and related packages.

Happy creating. <3

1 Like

Hi @philc_unity , looks like MARS v1.1.1 is not compatible with AR Foundation 4.0.2. I am working on a MARS project using AR Foundation 4.0.2, but I get errors when I upgrade to MARS v1.1.1.

It is the same errors I get if I install MARS v1.1.1 in a new project, which installs AR Foundation v2.1.8 and then I upgrade ARF to v4.0.2. Will you be fixing this? What do you recommend?

Here are three of the errors:
Library\PackageCache\com.unity.mars-ar-foundation-providers@1.1.1\Runtime\Scripts\ARFoundationCameraProvider.cs(43,16): error CS0104: ‘CameraFacingDirection’ is an ambiguous reference between ‘UnityEngine.XR.ARFoundation.CameraFacingDirection’ and ‘Unity.MARS.Data.CameraFacingDirection’

Library\PackageCache\com.unity.mars-ar-foundation-providers@1.1.1\Runtime\Scripts\ARFoundationCameraProvider.cs(169,37): error CS0539: ‘ARFoundationCameraProvider.RequestCameraFacingDirection(CameraFacingDirection)’ in explicit interface declaration is not a member of interface

Library\PackageCache\com.unity.mars-ar-foundation-providers@1.1.1\Runtime\Scripts\ARFoundationCameraProvider.cs(24,47): error CS0535: ‘ARFoundationCameraProvider’ does not implement interface member ‘IProvidesCameraTexture.RequestCameraFacingDirection(CameraFacingDirection)’

hello @flyingaudio ,

This is a known issue and a patch has been released for it, Please download version 1.1.2 from the package manager and your issue should be fixed.

Terrific. Thank you.

1 Like

Hey there!

To be clear, the fix is in the 1.1.2 version of com.unity.mars-ar-foundation-providers. The latest version of com.unity.mars and the rest of the packages supporting MARS is still 1.1.1

1 Like