@@ -13,7 +13,7 @@ namespace HoloToolkit.Unity.Receivers
1313 /// An interaction receiver is simply a component that attached to a list of interactable objects and does something
1414 /// based on events from those interactable objects. This is the base abstract class to extend from.
1515 /// </summary>
16- public abstract class InteractionReceiver : MonoBehaviour , IInputHandler , IHoldHandler , IInputClickHandler
16+ public abstract class InteractionReceiver : MonoBehaviour , IInputHandler , IHoldHandler , IInputClickHandler , IManipulationHandler
1717 {
1818 #region Public Members
1919 /// <summary>
@@ -31,11 +31,25 @@ public abstract class InteractionReceiver : MonoBehaviour, IInputHandler, IHoldH
3131 /// <summary>
3232 /// Flag for locking focus while selected
3333 /// </summary>
34- [ Tooltip ( "If true, this object will remain the prime focus while select is held" ) ]
35- public bool _LockFocus ;
34+ public bool LockFocus
35+ {
36+ get
37+ {
38+ return lockFocus ;
39+ }
40+ set
41+ {
42+ lockFocus = value ;
43+ CheckLockFocus ( _selectingFocuser ) ;
44+ }
45+ }
3646 #endregion
3747
3848 #region Private and Protected Members
49+ [ Tooltip ( "If true, this object will remain the prime focus while select is held" ) ]
50+ [ SerializeField ]
51+ private bool lockFocus = false ;
52+
3953 /// <summary>
4054 /// Protected focuser for the current selecting focuser
4155 /// </summary>
@@ -148,27 +162,39 @@ protected bool Isinteractable(GameObject interactable)
148162
149163 private void CheckLockFocus ( IPointingSource focuser )
150164 {
151- if ( _LockFocus )
165+ // If our previous selecting focuser isn't the same
166+ if ( _selectingFocuser != null && _selectingFocuser != focuser )
167+ {
168+ // If our focus is currently locked, unlock it before moving on
169+ if ( LockFocus )
170+ {
171+ _selectingFocuser . FocusLocked = false ;
172+ }
173+ }
174+
175+ // Set to the new focuser
176+ _selectingFocuser = focuser ;
177+ if ( _selectingFocuser != null )
152178 {
153- // LockFocus(focuser) ;
179+ _selectingFocuser . FocusLocked = LockFocus ;
154180 }
155181 }
156182
157- private void LockFocus ( IPointingSource focuser )
183+ private void LockFocuser ( IPointingSource focuser )
158184 {
159185 if ( focuser != null )
160186 {
161- ReleaseFocus ( ) ;
187+ ReleaseFocuser ( ) ;
162188 _selectingFocuser = focuser ;
163- // _selectingFocuser.LockFocus() ;
189+ _selectingFocuser . FocusLocked = true ;
164190 }
165191 }
166192
167- private void ReleaseFocus ( )
193+ private void ReleaseFocuser ( )
168194 {
169195 if ( _selectingFocuser != null )
170196 {
171- // _selectingFocuser.ReleaseFocus() ;
197+ _selectingFocuser . FocusLocked = false ;
172198 _selectingFocuser = null ;
173199 }
174200 }
@@ -193,6 +219,8 @@ private void OnPointerSpecificFocusChanged(IPointingSource pointer, GameObject o
193219 {
194220 FocusExit ( oldFocusedObject , eventData ) ;
195221 }
222+
223+ CheckLockFocus ( pointer ) ;
196224 }
197225
198226 #region Global Listener Callbacks
0 commit comments