1- using System ;
1+ using System ;
22using UnityEngine ;
33using UnityEditor ;
44
@@ -26,6 +26,7 @@ class AuthenticationView : Subview
2626 [ NonSerialized ] private bool need2fa ;
2727 [ NonSerialized ] private bool busy ;
2828 [ NonSerialized ] private string message ;
29+ [ NonSerialized ] private bool enterPressed ;
2930
3031 [ NonSerialized ] private AuthenticationService authenticationService ;
3132 private AuthenticationService AuthenticationService
@@ -73,6 +74,8 @@ public override void OnHide()
7374
7475 public override void OnGUI ( )
7576 {
77+ HandleEnterPressed ( ) ;
78+
7679 scroll = GUILayout . BeginScrollView ( scroll ) ;
7780 {
7881 Rect authHeader = EditorGUILayout . BeginHorizontal ( Styles . AuthHeaderBoxStyle ) ;
@@ -116,6 +119,16 @@ public override void OnGUI()
116119 GUILayout . EndScrollView ( ) ;
117120 }
118121
122+ private void HandleEnterPressed ( )
123+ {
124+ if ( Event . current . type != EventType . KeyDown )
125+ return ;
126+
127+ enterPressed = Event . current . keyCode == KeyCode . Return || Event . current . keyCode == KeyCode . KeypadEnter ;
128+ if ( enterPressed )
129+ Event . current . Use ( ) ;
130+ }
131+
119132 private void OnGUILogin ( )
120133 {
121134 GUILayout . Space ( 3 ) ;
@@ -142,7 +155,7 @@ private void OnGUILogin()
142155 if ( busy ) GUI . enabled = false ;
143156 GUILayout . BeginHorizontal ( ) ;
144157 GUILayout . FlexibleSpace ( ) ;
145- if ( GUILayout . Button ( loginButton ) )
158+ if ( GUILayout . Button ( loginButton ) || ( GUI . enabled && enterPressed ) )
146159 {
147160 GUI . FocusControl ( null ) ;
148161 busy = true ;
@@ -185,7 +198,7 @@ private void OnGUI2FA()
185198
186199 GUILayout . Space ( Styles . BaseSpacing ) ;
187200
188- if ( GUILayout . Button ( twofaButton ) )
201+ if ( GUILayout . Button ( twofaButton ) || ( GUI . enabled && enterPressed ) )
189202 {
190203 GUI . FocusControl ( null ) ;
191204 busy = true ;
0 commit comments