UnityEditor.MetroCreateTestCertificateWindow.OnGUI C# (CSharp) Method

OnGUI() public method

public OnGUI ( ) : void
return void
        public void OnGUI()
        {
            Event current = Event.current;
            bool flag = false;
            bool flag2 = false;
            if (current.type == EventType.KeyDown)
            {
                flag = current.keyCode == KeyCode.Escape;
                flag2 = (current.keyCode == KeyCode.Return) || (current.keyCode == KeyCode.KeypadEnter);
            }
            using (HorizontalLayout.DoLayout())
            {
                GUILayout.Space(10f);
                using (VerticalLayout.DoLayout())
                {
                    GUILayout.FlexibleSpace();
                    using (HorizontalLayout.DoLayout())
                    {
                        GUILayoutOption[] options = new GUILayoutOption[] { kLabelWidth };
                        GUILayout.Label(EditorGUIUtility.TextContent("Publisher|Publisher of the package."), options);
                        GUI.SetNextControlName("publisher");
                        this.publisher = GUILayout.TextField(this.publisher, new GUILayoutOption[0]);
                    }
                    GUILayout.Space(5f);
                    using (HorizontalLayout.DoLayout())
                    {
                        GUILayoutOption[] optionArray2 = new GUILayoutOption[] { kLabelWidth };
                        GUILayout.Label(EditorGUIUtility.TextContent("Password|Certificate password."), optionArray2);
                        GUI.SetNextControlName("password");
                        this.password = GUILayout.PasswordField(this.password, '●', new GUILayoutOption[0]);
                    }
                    GUILayout.Space(5f);
                    using (HorizontalLayout.DoLayout())
                    {
                        GUILayoutOption[] optionArray3 = new GUILayoutOption[] { kLabelWidth };
                        GUILayout.Label(EditorGUIUtility.TextContent("Confirm password|Re-enter certificate password."), optionArray3);
                        GUI.SetNextControlName("confirm");
                        this.confirm = GUILayout.PasswordField(this.confirm, '●', new GUILayoutOption[0]);
                    }
                    GUILayout.Space(10f);
                    using (HorizontalLayout.DoLayout())
                    {
                        GUILayout.Label(this.message, this.messageStyle, new GUILayoutOption[0]);
                        GUILayout.FlexibleSpace();
                        GUILayoutOption[] optionArray4 = new GUILayoutOption[] { kButtonWidth };
                        if (GUILayout.Button(EditorGUIUtility.TextContent("Create"), optionArray4) || flag2)
                        {
                            this.message = GUIContent.none;
                            if (string.IsNullOrEmpty(this.publisher))
                            {
                                this.message = EditorGUIUtility.TextContent("Publisher must be specified.");
                                this.focus = "publisher";
                            }
                            else if (this.password != this.confirm)
                            {
                                if (string.IsNullOrEmpty(this.confirm))
                                {
                                    this.message = EditorGUIUtility.TextContent("Confirm the password.");
                                    this.focus = "confirm";
                                }
                                else
                                {
                                    this.message = EditorGUIUtility.TextContent("Passwords do not match.");
                                    this.password = string.Empty;
                                    this.confirm = this.password;
                                    this.focus = "password";
                                }
                            }
                            else
                            {
                                try
                                {
                                    EditorUtility.WSACreateTestCertificate(this.path, this.publisher, this.password, true);
                                    AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
                                    if (!PlayerSettings.WSA.SetCertificate(FileUtil.GetProjectRelativePath(this.path), this.password))
                                    {
                                        this.message = EditorGUIUtility.TextContent("Invalid password.");
                                    }
                                    flag = true;
                                }
                                catch (UnityException exception)
                                {
                                    Debug.LogError(exception.Message);
                                }
                            }
                        }
                    }
                    GUILayout.FlexibleSpace();
                }
                GUILayout.Space(10f);
            }
            if (flag)
            {
                base.Close();
            }
            else if (this.focus != null)
            {
                EditorGUI.FocusTextInControl(this.focus);
                this.focus = null;
            }
        }
MetroCreateTestCertificateWindow