BlueGit

blue-star ggj-2020

Files

ggj-2020 / Assets / Oculus / VR / Scripts / Util / OVRPointerEventData.cs

OVRPointerEventData.cs

Project Import
timfa Tim Falken · pushed by timfa · 6 years ago
b77834a1 History
OVRPointerEventData.cs 3.4 KiB Download Raw
1/************************************************************************************
2Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
3
4Licensed under the Oculus Utilities SDK License Version 1.31 (the "License"); you may not use
5the Utilities SDK except in compliance with the License, which is provided at the time of installation
6or download, or which otherwise accompanies this software in either electronic or hard copy form.
7
8You may obtain a copy of the License at
9https://developer.oculus.com/licenses/utilities-1.31
10
11Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
12under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
13ANY KIND, either express or implied. See the License for the specific language governing
14permissions and limitations under the License.
15************************************************************************************/
16
17using System;
18using System.Text;
19using UnityEngine;
20using UnityEngine.Assertions;
21
22
23namespace UnityEngine.EventSystems
24{
25 /// <summary>
26 /// Extension of Unity's PointerEventData to support ray based pointing and also touchpad swiping
27 /// </summary>
28 public class OVRPointerEventData : PointerEventData
29 {
30 public OVRPointerEventData(EventSystem eventSystem)
31 : base(eventSystem)
32 {
33
34 }
35
36 public Ray worldSpaceRay;
37 public Vector2 swipeStart;
38
39 public override string ToString()
40 {
41 var sb = new StringBuilder();
42 sb.AppendLine("<b>Position</b>: " + position);
43 sb.AppendLine("<b>delta</b>: " + delta);
44 sb.AppendLine("<b>eligibleForClick</b>: " + eligibleForClick);
45 sb.AppendLine("<b>pointerEnter</b>: " + pointerEnter);
46 sb.AppendLine("<b>pointerPress</b>: " + pointerPress);
47 sb.AppendLine("<b>lastPointerPress</b>: " + lastPress);
48 sb.AppendLine("<b>pointerDrag</b>: " + pointerDrag);
49 sb.AppendLine("<b>worldSpaceRay</b>: " + worldSpaceRay);
50 sb.AppendLine("<b>swipeStart</b>: " + swipeStart);
51 sb.AppendLine("<b>Use Drag Threshold</b>: " + useDragThreshold);
52 return sb.ToString();
53 }
54
55 }
56
57
58 /// <summary>
59 /// Static helpers for OVRPointerEventData.
60 /// </summary>
61 public static class PointerEventDataExtension
62 {
63
64 public static bool IsVRPointer(this PointerEventData pointerEventData)
65 {
66 return (pointerEventData is OVRPointerEventData);
67 }
68 public static Ray GetRay(this PointerEventData pointerEventData)
69 {
70 OVRPointerEventData vrPointerEventData = pointerEventData as OVRPointerEventData;
71 Assert.IsNotNull(vrPointerEventData);
72
73 return vrPointerEventData.worldSpaceRay;
74 }
75 public static Vector2 GetSwipeStart(this PointerEventData pointerEventData)
76 {
77 OVRPointerEventData vrPointerEventData = pointerEventData as OVRPointerEventData;
78 Assert.IsNotNull(vrPointerEventData);
79
80 return vrPointerEventData.swipeStart;
81 }
82 public static void SetSwipeStart(this PointerEventData pointerEventData, Vector2 start)
83 {
84 OVRPointerEventData vrPointerEventData = pointerEventData as OVRPointerEventData;
85 Assert.IsNotNull(vrPointerEventData);
86
87 vrPointerEventData.swipeStart = start;
88 }
89
90
91
92
93 }
94}