unity VuforiaのVirtualButtonについてです。
まず下のコードですが
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using Vuforia; 5 6public class vbScript : MonoBehaviour,Vuforia.IVirtualButtonEventHandler { 7 8 GameObject virtualButtonObject ; 9 10 // Use this for initialization 11 void Start () { 12 13 virtualButtonObject = GameObject.Find ("actionButton"); 14 virtualButtonObject.GetComponent<VirtualButtonBehaviour> ().RegisterEventHandler (this); 15 16 17 } 18 19 // Update is called once per frame 20 void Update () { 21 22 23 24 } 25 26 public void OnButtonPressed(VirtualButtonAbstractBehaviour vb){ 27 28 Debug.Log ("ButtonPressed"); 29 30 } 31 32 public void OnButtonReleased(VirtualButtonAbstractBehaviour vb){ 33 34 } 35 36} 37
これは私がVirtualButtonを実装するために
この動画をみて書いたものです。
ここでvirtualButtonObject.GetComponent<VirtualButtonBehaviour> ().RegisterEventHandler (this);
この意味なのですがこれは何をしているのでしょうか?
参考までに
C#
1public void RegisterEventHandler (IVirtualButtonEventHandler eventHandler);
次にオーバーライドについて質問です。
下のコードはIVirtualButtonEventHandler インターフェースのメソッドをオーバーライドしていると思うのですが
これでなぜVirtualButtonを認識できるようになるのでしょうか?
(VirtualButtonを認識できる実装はどこに書いてあるのか?)
よろしくお願いします。
C#
1public void OnButtonPressed(VirtualButtonAbstractBehaviour vb){ 2 3 Debug.Log ("ButtonPressed"); 4 5 } 6 7 public void OnButtonReleased(VirtualButtonAbstractBehaviour vb){ 8 9 }
C#
1using System; 2 3namespace Vuforia 4{ 5 public interface IVirtualButtonEventHandler 6 { 7 // 8 // Methods 9 // 10 void OnButtonPressed (VirtualButtonAbstractBehaviour vb); 11 12 void OnButtonReleased (VirtualButtonAbstractBehaviour vb); 13 } 14} 15
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/10/28 05:25
2017/10/28 06:04
2017/10/28 13:26
2017/10/28 14:11
2017/10/28 14:22
2017/10/29 01:26
2017/10/29 12:15
2017/10/29 12:30
2017/10/29 13:43