@@ -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