IMHOTEP Framework
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
CameraDirectionTracker.cs
1 using UnityEngine;
2 using System.Collections;
3 
4 
8 public class CameraDirectionTracker : MonoBehaviour {
9 
10  // Use this for initialization
11  void Start () {
12 
13  }
14 
15  void Update () {
16  // Get a ray which looks forward from the camera's position:
17  Ray ray = new Ray (transform.position, transform.forward);
18 
19  // Shoot the ray only at the UIMesh, ignore everything else:
20  LayerMask mask = (1 << LayerMask.NameToLayer ("UIMesh"));
21 
22  RaycastHit result;
23  if (Physics.Raycast (ray, out result, Mathf.Infinity, mask)) {
24  // Let the Layout System know at what position we're looking (so it can decide which screen to activate):
25  UI.Core.instance.layoutSystem.setLookAtPosition (result.textureCoord);
26  }
27  }
28 }