public void OnGUI()
{
var e = Event.current;
var close = false;
var enter = false;
if (e.type == EventType.KeyDown)
{
close = (e.keyCode == KeyCode.Escape);
enter = ((e.keyCode == KeyCode.Return) || (e.keyCode == KeyCode.KeypadEnter));
}
using (HorizontalLayout.DoLayout())
{
GUILayout.Space(kSpace * 2);
using (VerticalLayout.DoLayout())
{
GUILayout.FlexibleSpace();
using (HorizontalLayout.DoLayout())
{
GUILayout.Label(EditorGUIUtility.TrTextContent("Password", "Certificate password."), kLabelWidth);
GUI.SetNextControlName(kPasswordId);
password = GUILayout.PasswordField(password, kPasswordChar);
}
GUILayout.Space(kSpace * 2);
using (HorizontalLayout.DoLayout())
{
GUILayout.Label(message, messageStyle);
GUILayout.FlexibleSpace();
if (GUILayout.Button(EditorGUIUtility.TrTextContent("Ok"), kButtonWidth) || enter)
{
message = GUIContent.none;
try
{
if (PlayerSettings.WSA.SetCertificate(path, password))
{
close = true;
}
else
{
message = EditorGUIUtility.TrTextContent("Invalid password.");
}
}
catch (UnityException ex)
{
Debug.LogError(ex.Message);
}
}
}
GUILayout.FlexibleSpace();
}
GUILayout.Space(kSpace * 2);
}
if (close)
{
Close();
}
else if (focus != null)
{
EditorGUI.FocusTextInControl(focus);
focus = null;
}
}