HoloPlay SDK Button Tutorial


Is there anyway to get a How-To for setting up the LG buttons to perform functions? As a non-Unity/Unreal user, I haven’t been able to figure it out. Ex. I’m trying to make one button pause the whole game, and this is as close as I got. (Holding down the circle pauses game, but not everything.)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HoloPlay;

namespace HoloPlay.Extras
public class Pause : MonoBehaviour
public MeshRenderer[] buttons;

    Dictionary<ButtonType, string> buttonNames = new Dictionary<ButtonType, string>{
        { ButtonType.ONE, "Square / 1" },
        { ButtonType.TWO, "Left / 2" },
        { ButtonType.THREE, "Right / 3" },
        { ButtonType.FOUR, "Circle / 4" },
    // Toggles the time scale between 1 and 0.7
    // whenever the user hits the Fire1 button.

    void Update()
        int i = 0;
        foreach (var b in buttonNames)
            if (Buttons.GetButton(b.Key))
                if (Time.timeScale == 1.0f)
                    Time.timeScale = 0.0f;
                Time.timeScale = 1.0f;
                // Adjust fixed delta time according to timescale
                // The fixed delta time will now be 0.02 frames per real-time second
                Time.fixedDeltaTime = 0.02f * Time.timeScale;

I generally look for button events in the Update() function

At the top of the script, put in
using HoloPlay;
and then a sample Update() looks like:

void Update () {
   if (HoloPlay.Buttons.GetButtonDown (ButtonType.CIRCLE))
         Debug.Log ("circle!");
   if (HoloPlay.Buttons.GetButtonDown (ButtonType.LEFT))
        Debug.Log ("left!");
   if (HoloPlay.Buttons.GetButtonDown (ButtonType.RIGHT))
        Debug.Log ("right!");
   if (HoloPlay.Buttons.GetButtonDown (ButtonType.SQUARE))
        Debug.Log ("square!");

You can call functions or do anything you like in the if statements, just like if you’re looking for a key press with Input.GetKeyDown()

HoloPlay.Buttons has four functions useful for catching button events:

  • Buttons.GetAnyButtonDown() – is true for the first frame any button is pressed
  • Buttons.GetButtonDown(ButtonType) – is true for the first frame when a given ButtonType is pressed (like ButtonType.LEFT, ButtonType.RIGHT, etc)
  • Buttons.GetButtonUp(ButtonType) – is true for the first frame when a given ButtonType is released
  • Buttons.GetButton(ButtonType) – returns the state ( true/false) for a given ButtonType at that moment

Hope this helps


Thanks! That helped a lot. My pause button is now working.



(discourse requires at least 20 characters in a post)


How to get hand interaction(LeapMotion) button actions?


That’s a whole different topic - this tutorial from Leap Motion is a good start.