Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice
  2. Read here for Unity's latest plans on OpenXR.
    Dismiss Notice

Help Wanted Changing the MARS Session World Scale at runtime.

Discussion in 'Unity MARS' started by shiftybit, Aug 31, 2020.

  1. shiftybit


    Nov 11, 2016
    Hi Folks,

    I want to build in functionality that will allow the user to pinch the screen and change the scale of the model to either desktop size, or real life size.

    I understand that the best way to scale objects is to use the World Scale on the MARS Session.

    I noticed that the World Scale slider is disabled when the in play mode. So my question; is it possible to change the World Scale at runtime, and if so how?

    Many thanks,
  2. unity_andrewm


    Unity Technologies

    Jun 25, 2015
    Hi Shifty,

    It depends exactly on what you want to scale. If it's just visual content, then you can adjust the object's transform directly.
    In real time, if you do need to manipulate world scale you can adjust the local transform of the MARSSession (which will in-turn scale the camera). Note you don't have the finer tuned control we normally provide during edit time - such as scaling conditions to keep relative poses the same, or the ability to scale lighting or camera planes. You'd need to do those parts yourself.
    shiftybit likes this.
  3. mtschoen


    Unity Technologies

    Aug 16, 2016
    Hi there!

    Thanks for the reply, @unity_andrewm. I just want to add a bit more context here:

    The "World Scale" feature is editor-only, as it works by collecting all the objects of a certain type (Proxy, AudioSource, etc.) and applying scaling to them, which is inefficient at runtime. The idea is that this will help you solve world scale problems at author time, but it is not intended to allow you to dynamically adjust world scale at runtime. There are more factors to consider when modifying world scale at runtime, such as systems that instantiate objects or manipulate their transforms while scaling is happening. We can't guarantee that a world scale change will "just work" at runtime.

    If you want to modify the scale applied to the camera and AR space, as @unity_andrewm mentioned, you can modify that transform directly. We also provide the `IUsesCameraOffset` functionality interface to provide more controlled access to session scale, rotation, and translation. It may be necessary to make your changes through this API for any systems which rely on cached values for camera scale.
    shiftybit likes this.