Skip to content

App Bar and Bounding Box

Lars Simkins edited this page Aug 7, 2017 · 6 revisions

Unity Test Scene

You can find the samples in the scene ManipulationGizmo_Examples.unity under https://github.com/Microsoft/MRDesignLabs_Unity/tree/master/DesignLabs_Unity_Examples/Assets/MRDL_ControlsExample/Scenes


There are three components to ensure the App Bar and Bounding Box work inside of your Unity project.

The first is the BoundingBoxTarget.cs component. If an InteractableObject with a BoundingBoxTarget.cs component is interacted with, it will request the App bar and take it from the last interacted object. It essentially is the glue to make all of the MRDesignLab manipulation components talk to each other. Assign BoundingBoxTarget.cs script to any objects that you want to use bounding box and app bar.

The ManipulationManager.cs component makes it easy to ensure that the prefabs necessary for BoundingBoxTarget.cs to function are present in your scene. This singleton instantiates AppBar.prefab and BoundingBoxShell.prefab on startup and provides properties to access them both.

The second, AppBar.prefab, behaves much like a singleton. You only need one in your scene hierarchy. The AppBar.prefab has a AppBar.cs script which handles all of the properties of how and what the Holobar should display.

The third is the BoundingBoxShell.prefab. This prefab works much like the AppBar.prefab. You only need one bounding box in the scene. If an object in the scene is put into adjust mode, the object will take the bounding box from the last adjusted object. The prefab has two scripts associated with it. The BoundingBoxManipulate.cs script which does the actual manipulating of the object its currently assigned to. The other script is the BoundingBoxGizmoShell.cs prefab. This script handles the visual representation of the bounding box and renders the transform affordances dynamically.

This is only one way to use BoundingBox components. If you want a custom manipulation style or a unique look we recommend you extend the BoundingBox.cs and BoundingBoxGizmo.cs base classes to create your own BoundingBox prefabs.

Clone and open the project MRDesignLabs_Unity in Unity.

Use the HUX menu to create a new HoloLens camera instance

The default HololensCamera prefab provided in MRDesignLabs_Unity provides global event and input handling required for the Holobar and Bounding box to work. It can be found at /MRDesignLab/Hux/Prefab/Interface. Additionally, once MRDesignLabs is in your unity project, you can use the menu system to create an instance of the HoloLens default camera.

Interaction Manager under HoloLensCamera

Please make sure ManipulationTranslate is checked in InteractionManager in HoloLens object. (ManipulationTranslate and Navigation X/Y/Z gestures are mutually exclusive.)

The bounding box and app bar prefabs in the scene

You can find the AppBar.prefab in /MRDesignLab/HUX/Prefabs/Dialogs and the BoundingBox.prefab can be found in /MRDesignLab/HUX/Examples/Prefabs/Dialogs. Changes made to these prefabs will affect all scenes that use them.

Bounding Box Target script provides everything needed to enable object manipulation

Apply the BoundingBoxTarget.cs /MRDesignLab/HUX/Scripts/interaction/ script to any object in the scene to enable object manipulation. The script provides full customization of how the object can transform. The default set is Drag, ScaleUniform, and RotateY. You can also set your preference for bounding box flattening for extremely thin objects.