On the same GameObject that you have the LeapServiceProvider (or LeapXRServiceProvider) add the LeapImageRetreiver script. Create a new script as shown below and place it on the same GameObject:
using UnityEngine;
using Leap.Unity;
using Leap;
public class LeapImageController : MonoBehaviour
{
private Controller _controller;
private LeapXRServiceProvider _provider;
Texture2D tex2D;
public RenderTexture renTex;
private void Awake()
{
_provider = GetComponent();
if (_provider == null)
{
_provider = GetComponentInChildren();
}
if(_provider != null) _controller = _provider.GetLeapController();
}
void Start ()
{
if(_controller != null) _controller.ImageReady += onImageReady;
else Debug.LogWarning("Warning - Leap controller is null");
}
private void onImageReady(object sender, Leap.ImageEventArgs args)
{
if(tex2D == null)
{
tex2D = new Texture2D(args.image.Width, args.image.Height, TextureFormat.R8, false);
}
tex2D.LoadRawTextureData(args.image.Data(Leap.Image.CameraType.LEFT));
tex2D.Apply();
Graphics.Blit(tex2D, renTex);
}
}
In your Canvas create a Panel with a RawImage component. Create a RenderTexture and drag it into the Texture field of the RawImage. Also drag the RenderTexture into the RenTex public field in the Leap ImageController in the Inspector. The IR video from the LeapMotion camera will be displayed in the raw image in the UI.