###前提・実現したいこと
LeapMotionのScreenTapGestureを用いて、UnityのUIボタンを押したいと思っています。
###開発環境
- Unity 5.4.0
- Leap Motion 2.3.1
- Windows10
- C#
###発生している問題・エラーメッセージ
ScreenTapGesture自体は実行できているのですが、ここからどのようにすればボタンを押すことができるのかがわからない状態です。
その方法について教えていただけますでしょうか。
何卒よろしくお願いいたします。
C#
1using UnityEngine; 2using System.Collections; 3using Leap; 4using UnityEngine.UI; 5 6public class TapButton : MonoBehaviour 7{ 8 private Controller controller = new Controller(); 9 Gesture gesture; 10 11 // Use this for initialization 12 void Start() 13 { 14 // ジェスチャー有効化 15 controller.EnableGesture(Gesture.GestureType.TYPESCREENTAP); 16 } 17 18 // Update is called once per frame 19 void Update() 20 { 21 var frame = controller.Frame(); 22 var fingerCount = frame.Fingers.Count; 23 var gestures = frame.Gestures(); 24 var interactionBox = frame.InteractionBox; 25 26 if (frame.Fingers[0].IsValid) 27 { 28 Vector normalizedPosition = interactionBox.NormalizePoint(frame.Fingers[0].TipPosition); 29 normalizedPosition *= 10; 30 normalizedPosition.z = -normalizedPosition.z; 31 32 for (int i = 0; i < gestures.Count; i++) 33 { 34 // ジェスチャー結果取得 & 表示 35 gesture = gestures[i]; 36 switch (gesture.Type) 37 { 38 case Gesture.GestureType.TYPESCREENTAP: 39 ScreenTapGesture(); 40 break; 41 default: 42 break; 43 } 44 } 45 } 46 } 47 48 public void ScreenTapGesture() 49 { 50 var screentapGesture = new ScreenTapGesture(gesture); 51 controller.Config.SetFloat("Gesture.ScreenTap.MinForwardVelocity", 30.0f); 52 controller.Config.SetFloat("Gesture.ScreenTap.HistorySeconds", 0.5f); 53 controller.Config.SetFloat("Gesture.ScreenTap.MinDistance", 1.0f); 54 controller.Config.Save(); 55 Debug.Log("ScreenTap"); 56 } 57 58 Vector3 ToVector3(Vector v) 59 { 60 return new UnityEngine.Vector3(v.x, v.y, v.z); 61 } 62}
###試したこと
Unity UI Buttons + Leap Motion
上記を参考にしましたが、うまく実行できませんでした。
###補足情報(言語/FW/ツール等のバージョンなど)
ScreenTapGesture以外でもLeapMotionを用いてボタンを押す方法がございましたら、教えていただけると幸いです。
あなたの回答
tips
プレビュー