Skip to content

Commit 51fdf4e

Browse files
committed
fix(Pointers): use appropriate tip for determining pointer origin
Previously the Pointer and UIPointer would use the transform of the controller for the pointer origin and forward, but for SteamVR due to different controllers being at different orientations it would use a custom origin via the `GenerateControllerPointerOrigin` method. This is not required as the `tip/attach` GameObject in a SteamVR controller is already at the correct orientation for determining the appropriate pointer origin. This fix now ensures this tip is used for determining the pointer origin and the `GenerateControllerPointerOrigin` class has been deprecated as no other SDKs used it except for SteamVR and SteamVR already has a built in mechanism for dealing with this complication. The Pointer and UIPointer also have a new `Attached To` parameter which can be used to determine which GameObject the pointer is actually attached to, which helps when determining the pointer origin as if the pointer is not attached to a controller. The `Controller` parameter has also been deprecated and brought into line with other scripts that correctly name it `Controller Events`.
1 parent d6914ea commit 51fdf4e

File tree

15 files changed

+139
-181
lines changed

15 files changed

+139
-181
lines changed

Assets/VRTK/Documentation/API.md

Lines changed: 5 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,8 @@ Provides a basis of being able to emit a pointer from a specified GameObject.
12491249
* **Select After Hover Duration:** The amount of time the pointer can be over the same collider before it automatically attempts to select it. 0f means no selection attempt will be made.
12501250
* **Interact With Objects:** If this is checked then the pointer will be an extension of the controller and able to interact with Interactable Objects.
12511251
* **Grab To Pointer Tip:** If `Interact With Objects` is checked and this is checked then when an object is grabbed with the pointer touching it, the object will attach to the pointer tip and not snap to the controller.
1252-
* **Controller:** An optional controller that will be used to toggle the pointer. If the script is being applied onto a controller then this parameter can be left blank as it will be auto populated by the controller the script is on at runtime.
1252+
* **Attached To:** An optional GameObject that determines what the pointer is to be attached to. If this is left blank then the GameObject the script is on will be used.
1253+
* **Controller Events:** An optional Controller Events that will be used to toggle the pointer. If the script is being applied onto a controller then this parameter can be left blank as it will be auto populated by the controller the script is on at runtime.
12531254
* **Interact Use:** An optional InteractUse script that will be used when using interactable objects with pointer. If this is left blank then it will attempt to get the InteractUse script from the same GameObject and if it cannot find one then it will attempt to get it from the attached controller.
12541255
* **Custom Origin:** A custom transform to use as the origin of the pointer. If no pointer origin transform is provided then the transform the script is attached to is used.
12551256

@@ -7864,8 +7865,9 @@ Provides the ability to interact with UICanvas elements and the contained Unity
78647865
* **Click Method:** Determines when the UI Click event action should happen.
78657866
* **Attempt Click On Deactivate:** Determines whether the UI click action should be triggered when the pointer is deactivated. If the pointer is hovering over a clickable element then it will invoke the click action on that element. Note: Only works with `Click Method = Click_On_Button_Up`
78667867
* **Click After Hover Duration:** The amount of time the pointer can be over the same UI element before it automatically attempts to click it. 0f means no click attempt will be made.
7867-
* **Controller:** The controller that will be used to toggle the pointer. If the script is being applied onto a controller then this parameter can be left blank as it will be auto populated by the controller the script is on at runtime.
7868-
* **Pointer Origin Transform:** A custom transform to use as the origin of the pointer. If no pointer origin transform is provided then the transform the script is attached to is used.
7868+
* **Attached To:** An optional GameObject that determines what the pointer is to be attached to. If this is left blank then the GameObject the script is on will be used.
7869+
* **Controller Events:** The Controller Events that will be used to toggle the pointer. If the script is being applied onto a controller then this parameter can be left blank as it will be auto populated by the controller the script is on at runtime.
7870+
* **Custom Origin:** A custom transform to use as the origin of the pointer. If no pointer origin transform is provided then the transform the script is attached to is used.
78697871

78707872
### Class Variables
78717873

@@ -10075,17 +10077,6 @@ The GetControllerByIndex method returns the GameObject of a controller with a sp
1007510077

1007610078
The GetControllerOrigin method returns the origin of the given controller.
1007710079

10078-
#### GenerateControllerPointerOrigin/1
10079-
10080-
> `public abstract Transform GenerateControllerPointerOrigin(GameObject parent);`
10081-
10082-
* Parameters
10083-
* `GameObject parent` - The GameObject that the origin will become parent of. If it is a controller then it will also be used to determine the hand if required.
10084-
* Returns
10085-
* `Transform` - A generated Transform that contains the custom pointer origin.
10086-
10087-
The GenerateControllerPointerOrigin method can create a custom pointer origin Transform to represent the pointer position and forward.
10088-
1008910080
#### GetControllerLeftHand/1
1009010081

1009110082
> `public abstract GameObject GetControllerLeftHand(bool actual = false);`
@@ -10707,17 +10698,6 @@ The GetControllerByIndex method returns the GameObject of a controller with a sp
1070710698

1070810699
The GetControllerOrigin method returns the origin of the given controller.
1070910700

10710-
#### GenerateControllerPointerOrigin/1
10711-
10712-
> `public override Transform GenerateControllerPointerOrigin(GameObject parent)`
10713-
10714-
* Parameters
10715-
* `GameObject parent` - The GameObject that the origin will become parent of. If it is a controller then it will also be used to determine the hand if required.
10716-
* Returns
10717-
* `Transform` - A generated Transform that contains the custom pointer origin.
10718-
10719-
The GenerateControllerPointerOrigin method can create a custom pointer origin Transform to represent the pointer position and forward.
10720-
1072110701
#### GetControllerLeftHand/1
1072210702

1072310703
> `public override GameObject GetControllerLeftHand(bool actual = false)`
@@ -11324,17 +11304,6 @@ The GetControllerByIndex method returns the GameObject of a controller with a sp
1132411304

1132511305
The GetControllerOrigin method returns the origin of the given controller.
1132611306

11327-
#### GenerateControllerPointerOrigin/1
11328-
11329-
> `public override Transform GenerateControllerPointerOrigin(GameObject parent)`
11330-
11331-
* Parameters
11332-
* `GameObject parent` - The GameObject that the origin will become parent of. If it is a controller then it will also be used to determine the hand if required.
11333-
* Returns
11334-
* `Transform` - A generated Transform that contains the custom pointer origin.
11335-
11336-
The GenerateControllerPointerOrigin method can create a custom pointer origin Transform to represent the pointer position and forward.
11337-
1133811307
#### GetControllerLeftHand/1
1133911308

1134011309
> `public override GameObject GetControllerLeftHand(bool actual = false)`
@@ -11966,17 +11935,6 @@ The GetControllerByIndex method returns the GameObject of a controller with a sp
1196611935

1196711936
The GetControllerOrigin method returns the origin of the given controller.
1196811937

11969-
#### GenerateControllerPointerOrigin/1
11970-
11971-
> `public override Transform GenerateControllerPointerOrigin(GameObject parent)`
11972-
11973-
* Parameters
11974-
* `GameObject parent` - The GameObject that the origin will become parent of. If it is a controller then it will also be used to determine the hand if required.
11975-
* Returns
11976-
* `Transform` - A generated Transform that contains the custom pointer origin.
11977-
11978-
The GenerateControllerPointerOrigin method can create a custom pointer origin Transform to represent the pointer position and forward.
11979-
1198011938
#### GetControllerLeftHand/1
1198111939

1198211940
> `public override GameObject GetControllerLeftHand(bool actual = false)`
@@ -12600,17 +12558,6 @@ The GetControllerByIndex method returns the GameObject of a controller with a sp
1260012558

1260112559
The GetControllerOrigin method returns the origin of the given controller.
1260212560

12603-
#### GenerateControllerPointerOrigin/1
12604-
12605-
> `public override Transform GenerateControllerPointerOrigin(GameObject parent)`
12606-
12607-
* Parameters
12608-
* `GameObject parent` - The GameObject that the origin will become parent of. If it is a controller then it will also be used to determine the hand if required.
12609-
* Returns
12610-
* `Transform` - A generated Transform that contains the custom pointer origin.
12611-
12612-
The GenerateControllerPointerOrigin method can create a custom pointer origin Transform to represent the pointer position and forward.
12613-
1261412561
#### GetControllerLeftHand/1
1261512562

1261612563
> `public override GameObject GetControllerLeftHand(bool actual = false)`
@@ -13234,17 +13181,6 @@ The GetControllerByIndex method returns the GameObject of a controller with a sp
1323413181

1323513182
The GetControllerOrigin method returns the origin of the given controller.
1323613183

13237-
#### GenerateControllerPointerOrigin/1
13238-
13239-
> `public override Transform GenerateControllerPointerOrigin(GameObject parent)`
13240-
13241-
* Parameters
13242-
* `GameObject parent` - The GameObject that the origin will become parent of. If it is a controller then it will also be used to determine the hand if required.
13243-
* Returns
13244-
* `Transform` - A generated Transform that contains the custom pointer origin.
13245-
13246-
The GenerateControllerPointerOrigin method can create a custom pointer origin Transform to represent the pointer position and forward.
13247-
1324813184
#### GetControllerLeftHand/1
1324913185

1325013186
> `public override GameObject GetControllerLeftHand(bool actual = false)`
@@ -13867,17 +13803,6 @@ The GetControllerByIndex method returns the GameObject of a controller with a sp
1386713803

1386813804
The GetControllerOrigin method returns the origin of the given controller.
1386913805

13870-
#### GenerateControllerPointerOrigin/1
13871-
13872-
> `public override Transform GenerateControllerPointerOrigin(GameObject parent)`
13873-
13874-
* Parameters
13875-
* `GameObject parent` - The GameObject that the origin will become parent of. If it is a controller then it will also be used to determine the hand if required.
13876-
* Returns
13877-
* `Transform` - A generated Transform that contains the custom pointer origin.
13878-
13879-
The GenerateControllerPointerOrigin method can create a custom pointer origin Transform to represent the pointer position and forward.
13880-
1388113806
#### GetControllerLeftHand/1
1388213807

1388313808
> `public override GameObject GetControllerLeftHand(bool actual = false)`
@@ -14489,17 +14414,6 @@ The GetControllerByIndex method returns the GameObject of a controller with a sp
1448914414

1449014415
The GetControllerOrigin method returns the origin of the given controller.
1449114416

14492-
#### GenerateControllerPointerOrigin/1
14493-
14494-
> `public override Transform GenerateControllerPointerOrigin(GameObject parent)`
14495-
14496-
* Parameters
14497-
* _none_
14498-
* Returns
14499-
* `Transform` - A generated Transform that contains the custom pointer origin.
14500-
14501-
The GenerateControllerPointerOrigin method can create a custom pointer origin Transform to represent the pointer position and forward.
14502-
1450314417
#### GetControllerLeftHand/1
1450414418

1450514419
> `public override GameObject GetControllerLeftHand(bool actual = false)`
@@ -15111,17 +15025,6 @@ The GetControllerByIndex method returns the GameObject of a controller with a sp
1511115025

1511215026
The GetControllerOrigin method returns the origin of the given controller.
1511315027

15114-
#### GenerateControllerPointerOrigin/1
15115-
15116-
> `public override Transform GenerateControllerPointerOrigin(GameObject parent)`
15117-
15118-
* Parameters
15119-
* `GameObject parent` - The GameObject that the origin will become parent of. If it is a controller then it will also be used to determine the hand if required.
15120-
* Returns
15121-
* `Transform` - A generated Transform that contains the custom pointer origin.
15122-
15123-
The GenerateControllerPointerOrigin method can create a custom pointer origin Transform to represent the pointer position and forward.
15124-
1512515028
#### GetControllerLeftHand/1
1512615029

1512715030
> `public override GameObject GetControllerLeftHand(bool actual = false)`

Assets/VRTK/Source/SDK/Base/SDK_BaseController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ public virtual void OnControllerReady(ControllerHand hand)
320320
/// </summary>
321321
/// <param name="parent">The GameObject that the origin will become parent of. If it is a controller then it will also be used to determine the hand if required.</param>
322322
/// <returns>A generated Transform that contains the custom pointer origin.</returns>
323+
[System.Obsolete("GenerateControllerPointerOrigin has been deprecated and will be removed in a future version of VRTK.")]
323324
public abstract Transform GenerateControllerPointerOrigin(GameObject parent);
324325

325326
/// <summary>

Assets/VRTK/Source/SDK/Daydream/SDK_DaydreamController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ public override Transform GetControllerOrigin(VRTK_ControllerReference controlle
137137
/// </summary>
138138
/// <param name="parent">The GameObject that the origin will become parent of. If it is a controller then it will also be used to determine the hand if required.</param>
139139
/// <returns>A generated Transform that contains the custom pointer origin.</returns>
140+
[System.Obsolete("GenerateControllerPointerOrigin has been deprecated and will be removed in a future version of VRTK.")]
140141
public override Transform GenerateControllerPointerOrigin(GameObject parent)
141142
{
142143
return null;

Assets/VRTK/Source/SDK/Fallback/SDK_FallbackController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public override Transform GetControllerOrigin(VRTK_ControllerReference controlle
9999
/// </summary>
100100
/// <param name="parent">The GameObject that the origin will become parent of. If it is a controller then it will also be used to determine the hand if required.</param>
101101
/// <returns>A generated Transform that contains the custom pointer origin.</returns>
102+
[System.Obsolete("GenerateControllerPointerOrigin has been deprecated and will be removed in a future version of VRTK.")]
102103
public override Transform GenerateControllerPointerOrigin(GameObject parent)
103104
{
104105
return null;

Assets/VRTK/Source/SDK/HyperealVR/SDK_HyperealVRController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public override Transform GetControllerOrigin(VRTK_ControllerReference controlle
133133
/// </summary>
134134
/// <param name="parent">The GameObject that the origin will become parent of. If it is a controller then it will also be used to determine the hand if required.</param>
135135
/// <returns>A generated Transform that contains the custom pointer origin.</returns>
136+
[System.Obsolete("GenerateControllerPointerOrigin has been deprecated and will be removed in a future version of VRTK.")]
136137
public override Transform GenerateControllerPointerOrigin(GameObject parent)
137138
{
138139
return null;

Assets/VRTK/Source/SDK/Oculus/SDK_OculusController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ public override Transform GetControllerOrigin(VRTK_ControllerReference controlle
218218
/// </summary>
219219
/// <param name="parent">The GameObject that the origin will become parent of. If it is a controller then it will also be used to determine the hand if required.</param>
220220
/// <returns>A generated Transform that contains the custom pointer origin.</returns>
221+
[System.Obsolete("GenerateControllerPointerOrigin has been deprecated and will be removed in a future version of VRTK.")]
221222
public override Transform GenerateControllerPointerOrigin(GameObject parent)
222223
{
223224
return null;

Assets/VRTK/Source/SDK/Simulator/SDK_SimController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ public override Transform GetControllerOrigin(VRTK_ControllerReference controlle
156156
/// </summary>
157157
/// <param name="parent">The GameObject that the origin will become parent of. If it is a controller then it will also be used to determine the hand if required.</param>
158158
/// <returns>A generated Transform that contains the custom pointer origin.</returns>
159+
[System.Obsolete("GenerateControllerPointerOrigin has been deprecated and will be removed in a future version of VRTK.")]
159160
public override Transform GenerateControllerPointerOrigin(GameObject parent)
160161
{
161162
return null;

Assets/VRTK/Source/SDK/SteamVR/SDK_SteamVRController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ public override Transform GetControllerOrigin(VRTK_ControllerReference controlle
221221
/// </summary>
222222
/// <param name="parent">The GameObject that the origin will become parent of. If it is a controller then it will also be used to determine the hand if required.</param>
223223
/// <returns>A generated Transform that contains the custom pointer origin.</returns>
224+
[System.Obsolete("GenerateControllerPointerOrigin has been deprecated and will be removed in a future version of VRTK.")]
224225
public override Transform GenerateControllerPointerOrigin(GameObject parent)
225226
{
226227
switch (VRTK_DeviceFinder.GetHeadsetType(true))

Assets/VRTK/Source/SDK/Unity/SDK_UnityController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ public override Transform GetControllerOrigin(VRTK_ControllerReference controlle
230230
/// </summary>
231231
/// <param name="parent">The GameObject that the origin will become parent of. If it is a controller then it will also be used to determine the hand if required.</param>
232232
/// <returns>A generated Transform that contains the custom pointer origin.</returns>
233+
[System.Obsolete("GenerateControllerPointerOrigin has been deprecated and will be removed in a future version of VRTK.")]
233234
public override Transform GenerateControllerPointerOrigin(GameObject parent)
234235
{
235236
return null;

Assets/VRTK/Source/SDK/VRTK_SDK_Bridge.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public static Transform GetControllerOrigin(VRTK_ControllerReference controllerR
5252
return GetControllerSDK().GetControllerOrigin(controllerReference);
5353
}
5454

55+
[System.Obsolete("GenerateControllerPointerOrigin has been deprecated and will be removed in a future version of VRTK.")]
5556
public static Transform GenerateControllerPointerOrigin(GameObject parent)
5657
{
5758
return GetControllerSDK().GenerateControllerPointerOrigin(parent);

Assets/VRTK/Source/SDK/Ximmerse/SDK_XimmerseController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ public override Transform GetControllerOrigin(VRTK_ControllerReference controlle
197197
/// The GenerateControllerPointerOrigin method can create a custom pointer origin Transform to represent the pointer position and forward.
198198
/// </summary>
199199
/// <returns>A generated Transform that contains the custom pointer origin.</returns>
200+
[System.Obsolete("GenerateControllerPointerOrigin has been deprecated and will be removed in a future version of VRTK.")]
200201
public override Transform GenerateControllerPointerOrigin(GameObject parent)
201202
{
202203
return null;

Assets/VRTK/Source/Scripts/Internal/VRTK_VRInputModule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ protected virtual void Drag(VRTK_UIPointer pointer, List<RaycastResult> results)
316316

317317
protected virtual void Scroll(VRTK_UIPointer pointer, List<RaycastResult> results)
318318
{
319-
pointer.pointerEventData.scrollDelta = (pointer.controller != null ? pointer.controller.GetTouchpadAxis() : Vector2.zero);
319+
pointer.pointerEventData.scrollDelta = (pointer.controllerEvents != null ? pointer.controllerEvents.GetTouchpadAxis() : Vector2.zero);
320320
bool scrollWheelVisible = false;
321321
for (int i = 0; i < results.Count; i++)
322322
{

0 commit comments

Comments
 (0)