Skip to content

Instantly share code, notes, and snippets.

@Krewn
Last active January 3, 2016 09:49
Show Gist options
  • Save Krewn/8445335 to your computer and use it in GitHub Desktop.
Save Krewn/8445335 to your computer and use it in GitHub Desktop.
How to get started with the leap motion controller and Unity3D with c#
using UnityEngine;
using System.Collections;
using Leap;
public class GetFrame : MonoBehaviour {
private LeapManager manager; //This provides access to leap data
public Leap.Frame frame; //this is a home for leap frame
private Leap.Controller controller; //This interprites the data stream
private Leap.Listener listener; //This is the data stream
// Use this for initialization
void Start () {
manager = Camera.main.GetComponent<LeapManager>(); //This links to some leap data
listener = new Leap.Listener (); //initializes the listener
controller = new Leap.Controller (); //Initializes the controler
controller.AddListener (listener); //Pipes the listener stream into the controler
}
// Update is called once per frame
void Update () {
if(controller.IsConnected)//controller is a Controller object
{
frame = controller.Frame(); //Puts the controler information into the frame for export to other scripts
}
}
}
@Krewn
Copy link
Author

Krewn commented Jan 15, 2014

Enjoy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment