+3

Leap Motion

Dave 2 years ago updated by DaveToon 2 weeks ago 1

Hello everyone! I have recently acquired a Leap Motion controller which I am using to integrate with a new VR project using Unity. However I am having quite a difficult time getting it to work with Bolt. Does anyone have any clue how to make the Leap Motion and Bolt asset play nice together? I am simply trying to use fingers for interacting with UI and it is proving to be impossible. Any help is appreciated!

Bolt Version:
1.4.0f11
Unity Version:
2018.3.2f1
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):

I know this is old but recently solved this.  I am not a programmer at all but thought if I was able to make the Leap Motion virtual button trigger a normal Unity UI button then I could use that button in my Bolt flow.  After hours of research and trial and error (a real programmer could have done it in 2 minutes) I found the code to do it.
Put this on your button script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ButtonAction : MonoBehaviour
{
public void ClickMe()
{
GetComponent().onClick.Invoke();

}
}

Then drag this button onto the "On Press" function of the Leap motion button. Choose function "ClickMe" and now when you hit the Leap motion button it will press the UI button.