Skip to content

Commit 01876eb

Browse files
author
David Kline
authored
Merge pull request #2076 from PJBowron/useActivatedPointingController
SimpleSinglePointerSelector: connect pointer upon OnSourceDetected
2 parents dc21720 + e5609d0 commit 01876eb

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Assets/HoloToolkit/Input/Scripts/Focus/SimpleSinglePointerSelector.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,15 @@ public class SimpleSinglePointerSelector : MonoBehaviour, ISourceStateHandler, I
2121
[Tooltip("The cursor, if any, which should follow the selected pointer.")]
2222
public Cursor Cursor;
2323

24-
[Tooltip("True to search for a cursor if one isn't explicitly set.")]
25-
public bool SearchForCursorIfUnset = true;
24+
[Tooltip("If true, search for a cursor if one isn't explicitly set.")]
25+
[SerializeField]
26+
private bool searchForCursorIfUnset = true;
27+
public bool SearchForCursorIfUnset { get { return searchForCursorIfUnset; } set { searchForCursorIfUnset = value; } }
28+
29+
[Tooltip("If true, always select the best pointer available (OS behaviour does not autoselect).")]
30+
[SerializeField]
31+
private bool autoselectBestAvailable = false;
32+
public bool AutoselectBestAvailable { get { return autoselectBestAvailable; } set { autoselectBestAvailable = value; } }
2633

2734
#endregion
2835

@@ -72,7 +79,11 @@ private void OnDisable()
7279

7380
void ISourceStateHandler.OnSourceDetected(SourceStateEventData eventData)
7481
{
75-
// Nothing to do on source detected.
82+
// If a pointing controller just became available, set it as primary.
83+
if (autoselectBestAvailable && SupportsPointingRay(eventData))
84+
{
85+
ConnectBestAvailablePointer();
86+
}
7687
}
7788

7889
void ISourceStateHandler.OnSourceLost(SourceStateEventData eventData)
@@ -117,7 +128,7 @@ private void RemoveInputManagerListenerIfNeeded()
117128

118129
private void FindCursorIfNeeded()
119130
{
120-
if ((Cursor == null) && SearchForCursorIfUnset)
131+
if ((Cursor == null) && searchForCursorIfUnset)
121132
{
122133
Debug.LogWarningFormat(
123134
this,

0 commit comments

Comments
 (0)