2016-04-27 9 views
0

Hololense tutorial herehololens 101第3章: "=>"とは何ですか?第3章GazeGestureManager.csで

using UnityEngine; 
using UnityEngine.VR.WSA.Input; 

public class GazeGestureManager : MonoBehaviour 
{ 
    public static GazeGestureManager Instance { get; private set; } 

    // Represents the hologram that is currently being gazed at. 
    public GameObject FocusedObject { get; private set; } 

    GestureRecognizer recognizer; 

    // Use this for initialization 
    void Start() 
    { 
     Instance = this; 

     // Set up a GestureRecognizer to detect Select gestures. 
     recognizer = new GestureRecognizer(); 
     recognizer.TappedEvent += (source, tapCount, ray) => 
     { 
      // Send an OnSelect message to the focused object and its ancestors. 
      if (FocusedObject != null) 
      { 
       FocusedObject.SendMessageUpwards("OnSelect"); 
      } 
     }; 
     recognizer.StartCapturingGestures(); 
    } 

    // Update is called once per frame 
    void Update() 
    { 
     // Figure out which hologram is focused this frame. 
     GameObject oldFocusObject = FocusedObject; 

     // Do a raycast into the world based on the user's 
     // head position and orientation. 
     var headPosition = Camera.main.transform.position; 
     var gazeDirection = Camera.main.transform.forward; 

     RaycastHit hitInfo; 
     if (Physics.Raycast(headPosition, gazeDirection, out hitInfo)) 
     { 
      // If the raycast hit a hologram, use that as the focused object. 
      FocusedObject = hitInfo.collider.gameObject; 
     } 
     else 
     { 
      // If the raycast did not hit a hologram, clear the focused object. 
      FocusedObject = null; 
     } 

     // If the focused object changed this frame, 
     // start detecting fresh gestures again. 
     if (FocusedObject != oldFocusObject) 
     { 
      recognizer.CancelGestures(); 
      recognizer.StartCapturingGestures(); 
     } 
    } 
} 

私は本当にこの行を理解していない:

recognizer.TappedEvent += (source, tapCount, ray) => 

=>オペレータと何がある理由は、内部()は何ですかのためですか?

答えて

2

C#ラムダ演算子hereを見てください。それはブロックを左側の入力変数から分離します。ブロックがタップされたイベントで実行され、パラメータ(source、tapCount、ray)が渡され、ブロックで使用できるように見えます。

1

私はそれを "イベントやコールバックを処理するためのインラインデリゲート"と考えています。希望するもの:

0

これは、 "TappedEvent"イベントが発生した場合、これらのパラメータでこれらのパラメータを実行してください。

関連する問題