1 using System.Collections;
2 using System.Collections.Generic;
4 using UnityEngine.EventSystems;
12 [RequireComponent(typeof(Canvas))]
22 public bool isInteractible =
true;
28 public static List<AVR_Canvas> all_canvases {
29 get {
return _all_canvases; }
30 private set { _all_canvases = value; }
32 private static List<AVR_Canvas> _all_canvases =
new List<AVR_Canvas>();
38 public static List<AVR_Canvas> active_canvases {
39 get {
return _active_canvases; }
40 private set { _active_canvases = value; }
42 private static List<AVR_Canvas> _active_canvases =
new List<AVR_Canvas>();
47 public Canvas canvas {
get;
private set; }
50 if(all_canvases==null) all_canvases =
new List<AVR_Canvas>();
51 if(active_canvases==null) active_canvases =
new List<AVR_Canvas>();
53 all_canvases.Add(
this);
55 canvas = GetComponent<Canvas>();
58 AVR_DevConsole.cerror(
"AVR_Canvas does not have a Canvas component!",
this);
64 if (active_canvases.Contains(
this)) active_canvases.Remove(
this);
69 if (all_canvases.Contains(
this)) all_canvases.Remove(
this);
70 if (active_canvases.Contains(
this)) active_canvases.Remove(
this);
78 anchor_to_transform(null);
86 this.transform.SetParent(AVR_PlayerRig.Instance.MainCamera.transform,
true);
87 AVR_DevConsole.print(gameObject.name +
" anchored to player");
96 this.transform.SetParent(controller.transform,
true);
97 AVR_DevConsole.print(gameObject.name +
" anchored to controller");
108 Vector3 tmp = this.transform.position;
109 this.transform.SetParent(null,
true);
110 transform.position = tmp;
113 this.transform.SetParent(t,
true);
122 Plane canvasPlane =
new Plane();
123 canvasPlane.Set3Points(
125 transform.position + transform.right,
126 transform.position + transform.up
133 if (isInteractible && !active_canvases.Contains(
this)) active_canvases.Add(
this);
137 if (active_canvases.Contains(
this)) active_canvases.Remove(
this);
Monobehaviour but with an added URL button to a documentation page.
void OnPointerExit(PointerEventData eventData)
void OnPointerEnter(PointerEventData eventData)
override void OnDestroy()
Sets the documentation html file inside of Packages/com.avr.core/Documentation/html of a given class...
void anchor_to_controller(AVR_ControllerInputManager controller)
Anchors the canvas to a given vr controller.
Plane GetPlane()
Returns the 3d plane this canvas lies in
void anchor_to_world()
Anchors this canvas to the world. (Sets parent to null)
void anchor_to_player()
Anchors this canvas to the players HMD. Intended for HUD UI elements.
void anchor_to_transform(Transform t)
Anchor this canvas to a given transform. Effectively the same as calling transform.SetParent(...)
Represents a canvas for VR interaction purposes. Allows for interaction with the AVR_UIInteractionPro...