private void SendCredentials(bool register) { string username; string password; if (!TextFieldInput.TryGetText(UsernameInputName, out username)) { Debug.LogError("Failed to get text from username field."); return; } if (!TextFieldInput.TryGetText(PasswordInputName, out password)) { Debug.LogError("Failed to get text from password field."); return; } username = InputValidator.FmtAllLowercase(username); if (!InputValidator.IsValidEmail(username)) { Debug.LogError("Username must be a valid email address."); } else if (!InputValidator.IsValidPassword(password)) { Debug.LogError("Invalid password: Length must be between " + InputValidator.MinPasswordLength + " and " + InputValidator.MaxPasswordLength + " characters long."); } else { socket.Send(register ? "CreateAccountRequest" : "LoginRequest", loginServer, username, password); } }
public void Selected() { currentlySelected = this; if (textMesh.text == initialValue) textMesh.text = ""; textMesh.text += '|'; InputHandler.Instance.ListenToKeyDown(Tab, KeyCode.Tab); InputHandler.Instance.ListenToKeyDown(Return, KeyCode.Return); Button.ListenForMissedClick(gameObject.name, MissedClick); InputHandler.Instance.ListenToChars(OnInput); InputHandler.Instance.ListenToKey(OnBackspace, KeyCode.Backspace); }
public void Selected() { currentlySelected = this; if (textMesh.text == initialValue) { textMesh.text = ""; } textMesh.text += '|'; InputHandler.Instance.ListenToKeyDown(Tab, KeyCode.Tab); InputHandler.Instance.ListenToKeyDown(Return, KeyCode.Return); Button.ListenForMissedClick(gameObject.name, MissedClick); InputHandler.Instance.ListenToChars(OnInput); InputHandler.Instance.ListenToKey(OnBackspace, KeyCode.Backspace); }
private void SubmitCreate() { string playerName; if (!TextFieldInput.TryGetText(PlayerNameInput, out playerName)) { return; } if (!InputValidator.IsValidPlayerName(playerName)) { Debug.LogError("Character name must be letters only and be " + InputValidator.MinPlayerNameLength + " to " + InputValidator.MaxPlayerNameLength + " characters long."); return; } playerName = InputValidator.FmtAllLowercase(playerName); socket.Send("CreateCharacter", characterServer, playerName); uiManager.CloseAllWindows(); }
private void Deselected() { if (currentlySelected == this) { currentlySelected = null; } if (textMesh.text[textMesh.text.Length - 1] == '|') { textMesh.text = textMesh.text.Remove(textMesh.text.Length - 1); } if (backingText.Length == 0) { textMesh.text = initialValue; } InputHandler.Instance.StopListenToKeyDown(Tab, KeyCode.Tab); InputHandler.Instance.StopListenToKeyDown(Return, KeyCode.Return); Button.StopListenForMissedClick(gameObject.name, MissedClick); InputHandler.Instance.StopListenToChars(OnInput); InputHandler.Instance.StopListenToKey(OnBackspace, KeyCode.Backspace); }
private void Awake() { socket = GetComponent <NetSocket>(); uiManager = GetComponent <UiManager>(); if (socket == null || uiManager == null) { Debug.LogError("Missing required component."); return; } socket.RegisterRpcListener(this); socket.Events.OnConnectedToServer += ConnectedToServer; socket.Events.OnSocketStart += ConnectToLoginServer; socket.Events.OnFailedToConnect += ConnectFailed; socket.Events.OnDisconnectedFromServer += DisconnectedFromServer; Button.ListenForClick(LoginButtonName, LoginClicked); Button.ListenForClick(RegisterButtonName, RegisterClicked); TextFieldInput.ListenForSubmit(UsernameInputName, Submit); TextFieldInput.ListenForSubmit(PasswordInputName, Submit); }
void OnDisable() { Button.StopListenForClick(CreateButtonName, SubmitCreate); TextFieldInput.StopListenForSubmit(SubmitCreate); }
void OnEnable() { Button.ListenForClick(CreateButtonName, SubmitCreate); TextFieldInput.ListenForSubmit(PlayerNameInput, SubmitCreate); }
private void Deselected() { if (currentlySelected == this) currentlySelected = null; if (textMesh.text[textMesh.text.Length - 1] == '|') textMesh.text = textMesh.text.Remove(textMesh.text.Length - 1); if (backingText.Length == 0) textMesh.text = initialValue; InputHandler.Instance.StopListenToKeyDown(Tab, KeyCode.Tab); InputHandler.Instance.StopListenToKeyDown(Return, KeyCode.Return); Button.StopListenForMissedClick(gameObject.name, MissedClick); InputHandler.Instance.StopListenToChars(OnInput); InputHandler.Instance.StopListenToKey(OnBackspace, KeyCode.Backspace); }