VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
AVR_UIRay.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 
5 using AVR.Core;
6 
7 namespace AVR.UI {
8  /// <summary>
9  /// Represents a UI pointer-ray.
10  /// </summary>
11  [AVR.Core.Attributes.DocumentationUrl("class_a_v_r_1_1_u_i_1_1_a_v_r___u_i_ray.html")]
12  public class AVR_UIRay : AVR_Ray
13  {
14  [Header("UI Camera")]
15  /// <summary>
16  /// Camera that is the eventCamera for the underlying inputsystem. If left blank, a Camera with preset value will be added.
17  /// </summary>
18  public Camera UICamera;
19 
20  /// <summary>
21  /// Retocule object to display at the end of our ray.
22  /// </summary>
23  public GameObject reticule;
24 
25  [HideInInspector]
26  /// <summary>
27  /// Normal vector of the canvas we are hovering over (if there is one). This is set automatically by UIInteractionProvider.
28  /// </summary>
29  public Vector3 canvasNormal = Vector3.forward;
30 
31  protected override void Awake() {
32  if(!UICamera) {
33  UICamera = lr.gameObject.AddComponent<Camera>();
34  UICamera.clearFlags = CameraClearFlags.Nothing;
35  UICamera.cullingMask = 0;
36  UICamera.fieldOfView = 0.00001f;
37  UICamera.nearClipPlane = 0.01f;
38  UICamera.farClipPlane = 1000f;
39  UICamera.depth = 0f;
40  UICamera.allowHDR = false;
41  UICamera.allowMSAA = false;
42  UICamera.targetDisplay = 7;
43  UICamera.enabled = false;
44  }
45  if(mode!=RayMode.STRAIGHT) {
46  AVR_DevConsole.cwarn("AVR_UIRay was initialized with a mode other than RayMode.STRAIGHT! UIRays can only be straight.", this);
47  mode = RayMode.STRAIGHT;
48  }
49  base.Awake();
50  }
51 
52  protected override void Update()
53  {
54  base.Update();
55  if (reticule != null)
56  {
57  reticule.SetActive(isVisible);
58  if (isVisible)
59  {
60  reticule.transform.position = lr.GetPosition(lr.positionCount - 1);
61  reticule.transform.forward = -canvasNormal;
62  }
63  }
64  }
65  }
66 }
Represents a UI pointer-ray.
Definition: AVR_UIRay.cs:12
GameObject reticule
Retocule object to display at the end of our ray.
Definition: AVR_UIRay.cs:23
override void Awake()
Definition: AVR_UIRay.cs:31
override void Update()
Definition: AVR_UIRay.cs:52
Base class for a ray. A ray is always cast in transform.forward direction of the object it is attatch...
Definition: AVR_Ray.cs:13
Sets the documentation html file inside of Packages/com.avr.core/Documentation/html of a given class...
Camera UICamera
Camera that is the eventCamera for the underlying inputsystem. If left blank, a Camera with preset va...
Definition: AVR_UIRay.cs:18