1
- using System ;
1
+ using System ;
2
2
using UnityEngine ;
3
3
using UnityEditor ;
4
4
@@ -26,6 +26,7 @@ class AuthenticationView : Subview
26
26
[ NonSerialized ] private bool need2fa ;
27
27
[ NonSerialized ] private bool busy ;
28
28
[ NonSerialized ] private string message ;
29
+ [ NonSerialized ] private bool enterPressed ;
29
30
30
31
[ NonSerialized ] private AuthenticationService authenticationService ;
31
32
private AuthenticationService AuthenticationService
@@ -73,6 +74,8 @@ public override void OnHide()
73
74
74
75
public override void OnGUI ( )
75
76
{
77
+ HandleEnterPressed ( ) ;
78
+
76
79
scroll = GUILayout . BeginScrollView ( scroll ) ;
77
80
{
78
81
Rect authHeader = EditorGUILayout . BeginHorizontal ( Styles . AuthHeaderBoxStyle ) ;
@@ -116,6 +119,16 @@ public override void OnGUI()
116
119
GUILayout . EndScrollView ( ) ;
117
120
}
118
121
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
+
119
132
private void OnGUILogin ( )
120
133
{
121
134
GUILayout . Space ( 3 ) ;
@@ -142,7 +155,7 @@ private void OnGUILogin()
142
155
if ( busy ) GUI . enabled = false ;
143
156
GUILayout . BeginHorizontal ( ) ;
144
157
GUILayout . FlexibleSpace ( ) ;
145
- if ( GUILayout . Button ( loginButton ) )
158
+ if ( GUILayout . Button ( loginButton ) || ( GUI . enabled && enterPressed ) )
146
159
{
147
160
GUI . FocusControl ( null ) ;
148
161
busy = true ;
@@ -185,7 +198,7 @@ private void OnGUI2FA()
185
198
186
199
GUILayout . Space ( Styles . BaseSpacing ) ;
187
200
188
- if ( GUILayout . Button ( twofaButton ) )
201
+ if ( GUILayout . Button ( twofaButton ) || ( GUI . enabled && enterPressed ) )
189
202
{
190
203
GUI . FocusControl ( null ) ;
191
204
busy = true ;
0 commit comments