Hello!

Yesterday I wrote on how to connect an XBoxOne controller to a Hololens. Today I’ll share a bit of code on how to interact with the device. The example is simple

Once added the ability of Spatial Mapping in the project, we will activate the display of Visual Mesh when you press button A on the XBoxOne remote control

For example:

 

2017-03-01-holo-xboxone-controller-03

We started with the basics, creating a project vacuum in Unity3D and following these steps

  • Configure project to support HoloLens projects
  • Clean Scene elements
  • Import HoloToolkit package
  • Add
    • HololensCamera
    • SpatialMapping
    • CursorWithFeedback
  • Add Empty element, Managers
    • Add existing scripts
      • Gaze Managers
      • Gaze Stabilizer
      • Input Manager
    • Add new empty script
      • XboxControllerManager

After completion of the project would be similar to the following:

Clipboard02.jpg

Now we see the code required for the “XboxControllerManager” script. We will work on the Update(): check for button A pressed state, and let’s add that state to the DrawVisualMeshes property of the active instance of Spatial Mapping.

clipboard04

Done! This is good enough for a sample, although here it is convenient to study a bit about concepts that handles Unity for the “Inputs” (see references). In this case, in the project properties, we can see the basic settings for projects 3D in Unity in this aspect. And the main class for the States of the buttons on the remote control to access is UnityEngine.Input.

In the next post, when working with a kind of HoloToolkit for control of Xbox, comment the changes needed to make it work properly.

The source of the example source code can be downloaded from link.

Greetings @ Toronto

El Bruno

References

32 responses to “#Hololens – Fire Buttons actions with a #XBoxOne Controller”

  1. […] El Bruno, How to use Fire Buttons actions with an XBoxOne Controller […]

    Like

  2. […] El Bruno, How to use Fire Buttons actions with an XBoxOne Controller […]

    Like

  3. […] El Bruno, How to use Fire Buttons actions with an XBoxOne Controller […]

    Like

  4. […] El Bruno, How to use Fire Buttons actions with an XBoxOne Controller […]

    Like

  5. […] El Bruno, How to use Fire Buttons actions with an XBoxOne Controller […]

    Like

  6. […] El Bruno, How to use Fire Buttons actions with an XBoxOne Controller […]

    Like

  7. […] El Bruno, How to use Fire Buttons actions with an XBoxOne Controller […]

    Like

  8. […] El Bruno, How to use Fire Buttons actions with an XBoxOne Controller […]

    Like

  9. […] El Bruno, How to use Fire Buttons actions with an XBoxOne Controller […]

    Like

  10. […] How to use Fire Buttons actions with an XBoxOne Controller […]

    Like

  11. […] How to use Fire Buttons actions with an XBoxOne Controller […]

    Like

  12. […] How to use Fire Buttons actions with an XBoxOne Controller […]

    Like

  13. […] How to use Fire Buttons actions with an XBoxOne Controller […]

    Like

  14. […] How to use Fire Buttons actions with an XBoxOne Controller […]

    Like

  15. […] How to use Fire Buttons actions with an XBoxOne Controller […]

    Like

  16. […] How to use Fire Buttons actions with an XBoxOne Controller […]

    Like

Leave a reply to #Hololens – How to select an hologram, change size or position and more using #MRDesignLab – El Bruno Cancel reply

Discover more from El Bruno

Subscribe now to keep reading and get access to the full archive.

Continue reading