VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
WindowHandle.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 using UnityEngine.EventSystems;
5 
6 using AVR.Core;
7 using AVR;
8 using AVR.UI;
9 
10 namespace AVR.UI.Utils {
11  /// <summary>
12  /// Window-Handle that allows the attatched canvas to be click and dragged in world space by a UIInteractionProvider.
13  /// </summary>
14  [AVR.Core.Attributes.DocumentationUrl("class_a_v_r_1_1_u_i_1_1_utils_1_1_window_handle.html")]
15  public class WindowHandle : AVR_Behaviour, IPointerDownHandler, IPointerUpHandler
16  {
17  /// <summary>
18  /// Canvas that is moved by this handle
19  /// </summary>
21 
22  Transform og_parent = null;
23  bool clicked = false;
24 
25  void Awake() {
26  if(!canvas) {
27  canvas = GetComponentInParent<AVR_Canvas>();
28  if(!canvas) {
29  AVR_DevConsole.cerror("WindowHandle does not have an AVR_Canvas attatched!", this);
30  }
31  }
32  }
33 
34  public void OnPointerDown(PointerEventData eventData)
35  {
36  if(clicked) return;
37 
38  clicked = true;
39 
40  og_parent = canvas.transform.parent;
41  canvas.anchor_to_transform(AVR_UIInteractionProvider.currentActive.transform);
42  }
43 
44  public void OnPointerUp(PointerEventData eventData)
45  {
46  if (!clicked) return;
47 
48  clicked = false;
49 
50  canvas.anchor_to_transform(og_parent);
51  }
52  }
53 }
Monobehaviour but with an added URL button to a documentation page.
AVR_Canvas canvas
Canvas that is moved by this handle
Definition: WindowHandle.cs:20
void OnPointerDown(PointerEventData eventData)
Definition: WindowHandle.cs:34
Sets the documentation html file inside of Packages/com.avr.core/Documentation/html of a given class...
Window-Handle that allows the attatched canvas to be click and dragged in world space by a UIInteract...
Definition: WindowHandle.cs:15
void OnPointerUp(PointerEventData eventData)
Definition: WindowHandle.cs:44
Represents a canvas for VR interaction purposes. Allows for interaction with the AVR_UIInteractionPro...
Definition: AVR_Canvas.cs:17