public void PressActiveButton() { //press enter, we sohuld send a message or activate the input if (isInputActive) { //input was active, send the message, clear the inputField string message = inputField.text; if (message.Length > 0) { string username = LoginScript.CurrentUser; //string username = "******"; SendMessageString(username + ": " + message); JSONObject json_message = new JSONObject(); json_message.AddField("lobbyid", LoginScript.CurrentUserLobbyId); json_message.AddField("name", username); json_message.AddField("message", message); socket.Emit("chat message", json_message); inputField.text = ""; } inputField.DeactivateInputField(); EventSystem.current.SetSelectedGameObject(contentText.gameObject); } else {//input was nonactive inputField.Select(); inputField.ActivateInputField(); } }
private void OnApplicationQuit() { if (m_inputField != null) { m_inputField.DeactivateInputField(); } }
// Use this for initialization // Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.BackQuote)) { consoleCanvas.gameObject.SetActive(!consoleCanvas.gameObject.activeInHierarchy); if (consoleCanvas.gameObject.activeInHierarchy) { consoleInput.ActivateInputField(); } else { consoleInput.DeactivateInputField(); } consoleInput.text = ""; } if (consoleCanvas.gameObject.activeInHierarchy) { if (Input.GetKeyDown(KeyCode.Return)) { if (inputText.text != "") { AddMessageToConsole(inputText.text); ParseInput(inputText.text); } } } //consoleInput.text = ""; }
private void OnInputFieldSubmitted(string arg0) { string str = time_label.text.Split(':')[0] + time_label.text.Split(':')[1]; //AudioTimerInput.text = ""; if (source.clip.length > StringToSecondsCount(str, ref arg0)) { source.time = StringToSecondsCount(str, ref arg0); } else { Debug.LogWarning("length exceeds time remaining in clip"); } AudioTimerInput.DeactivateInputField(); if (GetComponentInParent <UIB_Page>().gameObject.GetComponent <Canvas>().isActiveAndEnabled) { PlayMethod(1); } if (TouchScreenKeyboard.isSupported) { if (AudioTimerInput.touchScreenKeyboard.status == TouchScreenKeyboard.Status.Done) { PlayMethod(1); } } #if (UNITY_IOS || UNITY_ANDROID) && !UNITY_EDITOR StartCoroutine("SetInputPositionBack"); #endif //TODO:deselect the input field }
public void UpdateCurrentInputField() { if (m_eventSystem.currentSelectedGameObject != null && m_eventSystem.currentSelectedGameObject.activeInHierarchy) { if (m_eventSystem.currentSelectedGameObject != m_currentSelectedGameObject) { m_currentSelectedGameObject = m_eventSystem.currentSelectedGameObject; if (m_currentSelectedGameObject != null) { m_currentInputField = m_currentSelectedGameObject.GetComponent <InputField>(); } else { if (m_currentInputField != null) { m_currentInputField.DeactivateInputField(); } m_currentInputField = null; } } } else { m_currentSelectedGameObject = null; if (m_currentInputField != null) { m_currentInputField.DeactivateInputField(); } m_currentInputField = null; } }
IEnumerator removeOne() { yield return(new WaitForEndOfFrame()); if (isFull == true) { isFull = false; if (targetInput.text.Length > prevLength) { targetInput.text = targetInput.text.Remove(targetInput.text.Length - 1); } targetInput.DeactivateInputField(); } else { if (targetInput.textComponent.preferredWidth > GetComponent <RectTransform> ().sizeDelta.x - targetInput.textComponent.fontSize) { isFull = true; prevLength = targetInput.text.Length; targetInput.DeactivateInputField(); //targetInput.text = targetInput.text.Remove (targetInput.text.Length - 1); } } }
public void LoadLevel() { string folder = Application.dataPath + "/LevelData"; string levelfile = ""; if (LoadlevelName.text == "") { levelfile = "new_level.json"; } else { levelfile = LoadlevelName.text + ".json"; } string path = Path.Combine(folder, levelfile); if (File.Exists(path)) { EditorObject[] Objectsfound = FindObjectsOfType <EditorObject>(); foreach (EditorObject obj in Objectsfound) { Destroy(obj.gameObject); } PlayerPlaced = false; string json = File.ReadAllText(path); level = JsonUtility.FromJson <LevelEditor>(json); CreateFromFile(); } else { SaveLoadMessage.text = levelfile + " Could not be found !"; LoadlevelName.DeactivateInputField(); } }
private void Focussed() { _backspaceClick = 0; TextEditorHotkeyController.Instance.RegisterForEnterKey(() => { ElementsController.Instance.AddNewElement(ElementType.Action, autoCreate: true); Blurred(); }); TextEditorHotkeyController.Instance.RegisterForEscapeKey(() => { InputField.DeactivateInputField(); OnBlur(); }); TextEditorHotkeyController.Instance.RegisterBackspaceKey(() => { if (string.IsNullOrEmpty(InputField.text)) { _backspaceClick++; if (_backspaceClick > 1) { InputField.DeactivateInputField(); OnBlur(); ElementsController.Instance.DeleteElement(UniqueId); } } }); }
// Update is called once per frame void Update() { // If the chat box is not empty if (chatBox.text != "") { // And we hit enter if (Input.GetKeyDown(KeyCode.Return)) { // Send the message! //SendMessageToChat(chatBox.text, Message.MessageType.playerMessage); client.GetComponent <Client>().PlayerSendMessage(chatBox.text); chatBox.text = ""; chatBox.DeactivateInputField(); } } // If the chat box was empty and we hit return, return focus to the game else if (Input.GetKeyDown(KeyCode.Return)) { chatBox.DeactivateInputField(); } // If the chat box was not focused and we hit enter, put focus on the chat box else if (!chatBox.isFocused && Input.GetKeyDown(KeyCode.Return)) { chatBox.ActivateInputField(); } }
// Start is called before the first frame update void Start() { inputField.DeactivateInputField(); inputField.gameObject.SetActive(false); playerField.gameObject.SetActive(true); playerField.ActivateInputField(); player.UnlockMouse(); notes = FindObjectOfType <PlayNotes>(); notes.typing = true; Debug.Log(playerField.isActiveAndEnabled); }
/** * Updates Time and check. */ void Update() { if (testTimer.myTimer == 0.0f && gamePlay) { wordText.text = "Game Over."; buttonTest.interactable = true; inputTest.interactable = false; inputTest.text = ""; inputTest.DeactivateInputField(); } }
// Use this for initialization void Start() { numerator.DeactivateInputField(); denominator.DeactivateInputField(); qnumerator.text = "1"; qdenominator.text = "3"; numerator.text = "" + num_digit; denominator.text = "" + den_digit; check.SetActive(false); wrong.SetActive(false); }
public void SaveLevelFromUI() { objectsInSceneToSave = FindObjectsOfType <Grid_Object>(); decorInSceneToSave = FindObjectsOfType <_DecorObject>(); //add the object's data to the savedObjectsData List foreach (Grid_Object sceneObject in objectsInSceneToSave) { levelData.savedObjectsData.Add(sceneObject.cubeData); } foreach (_DecorObject sceneDecor in decorInSceneToSave) { levelData.savedEnvironmentData.Add(sceneDecor.decorData); } string json = JsonUtility.ToJson(levelData); string folder = Application.dataPath + "/Scenes/_LevelsFolder"; string levelFile = ""; if (levelNameSave.text == "") { levelFile = "new_level.json"; } else { levelFile = levelNameSave.text + ".json"; } if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } string path = Path.Combine(folder, levelFile); if (File.Exists(path)) { File.Delete(path); } File.WriteAllText(path, json); levelNameSave.text = ""; levelNameSave.DeactivateInputField(); levelMessage.text = levelFile + " saved to ExistingLevels folder"; levelData.savedObjectsData.Clear(); levelData.savedEnvironmentData.Clear(); }
private void Start() { DontDestroyOnLoad(this); undo = new LinkedList <string>(); redo = new LinkedList <string>(); Vector3 pos = rectTransform.anchoredPosition3D; pos.y = yDisabled; rectTransform.anchoredPosition3D = pos; commandInput.DeactivateInputField(); commandInput.enabled = false; }
void OnTriggerEnter2D(Collider2D col) { if (col.CompareTag("Player")) { manager.unscramble.transform.parent.gameObject.SetActive(false); finalHint = manager.finalHint.ToString(); manager.cageDoorText.transform.parent.gameObject.SetActive(true); InputField field = manager.cageDoorText.transform.GetChild(0).GetComponent <InputField> (); manager.cageDoorText.color = Color.black; // check if all hints for the last puzzle have been found if (finalHint.Length == manager.currentWord.Length) { manager.cageDoorText.text = finalHint; field.ActivateInputField(); } else // if hints haven't been found { field.DeactivateInputField(); manager.cageDoorText.text = "No hint to show"; manager.cageDoorText.color = Color.red; } } }
// Update is called once per frame void Update() { if (chatclient != null) { chatclient.Service(); } if (chatclient != null && Input.GetKeyDown(KeyCode.Return)) { if (!input_focused) { chatInput.ActivateInputField(); input_focused = true; } else { if (chatInput.text != "") { chatclient.PublishMessage(current_channel, chatInput.text); chatInput.text = ""; Canvas.ForceUpdateCanvases(); chatPanel.GetComponentInChildren <ScrollRect>().verticalNormalizedPosition = 0f; } chatInput.DeactivateInputField(); input_focused = false; } } if (Input.GetMouseButtonDown(0)) { input_focused = false; } }
private void Update() { if (Input.GetKeyDown(KeyCode.Return)) { if (!scrollView.activeSelf && !textBox.activeSelf && !text.activeSelf) { scrollView.SetActive(true); textBox.SetActive(true); text.SetActive(true); chatBox.ActivateInputField(); } else if (chatBox.text == "") { scrollView.SetActive(false); textBox.SetActive(false); text.SetActive(false); chatBox.DeactivateInputField(); } if (chatBox.text != "") { SendMessageToChat(username + ": " + chatBox.text, Message.MessageType.playerMessage); chatBox.text = ""; chatBox.ActivateInputField(); } } }
public void SaveLevel() { EditorObject[] Objectsfound = FindObjectsOfType <EditorObject>(); foreach (EditorObject obj in Objectsfound) { level.editorObjects.Add(obj.data); } string json = JsonUtility.ToJson(level); string folder = Application.dataPath + "/LevelData"; string levelFile = ""; if (SaveLevelName.text == "") { levelFile = "new_level.json"; } else { levelFile = SaveLevelName.text + ".json"; } if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } string path = Path.Combine(folder, levelFile); if (File.Exists(path)) { File.Delete(path); } File.WriteAllText(path, json); SaveLevelName.text = ""; SaveLevelName.DeactivateInputField(); SaveLoadMessage.text = levelFile + " Saved to LevelData folder."; }
void InputFieldCancelFocus() { if (ip != null) { ip.DeactivateInputField(); } }
/// <summary> /// Set focus on field /// </summary> /// <param name="isFocus">true | false</param> public void SetFocus(bool isFocus) { #if (UNITY_IOS || UNITY_ANDROID) && !UNITY_EDITOR if (!_isMobileInputCreated) { _isFocusOnCreate = isFocus; return; } JsonObject data = new JsonObject(); data["msg"] = SET_FOCUS; data["is_focus"] = isFocus; this.Execute(data); #else if (gameObject.activeInHierarchy) { if (isFocus) { _inputObject.ActivateInputField(); } else { _inputObject.DeactivateInputField(); } } else { _isFocusOnCreate = isFocus; } #endif }
private int id; // ID for future use. // Use this for initialization void Start() { dbManage = GetComponent <DBManager>(); dbTest(); // If user is already logged in: if (dbManage.getStatus()) { // Display username errorDisplay.text = "Welcome " + dbManage.getUsername(); // Deactivate fields nameField.DeactivateInputField(); passwordField.DeactivateInputField(); submitButton.GetComponent <Button>().interactable = false; registerButton.GetComponent <Button>().interactable = false; } else { // Make password show up as astrisks passwordField.contentType = InputField.ContentType.Password; // Go to TaskOnClick when button is pressed submitButton.onClick.AddListener(TaskOnClick); } }
private void Start() { _scrollRect = GetComponentInParent <ScrollRect>(); _input = GetComponent <InputField>(); _input.DeactivateInputField(); _input.enabled = false; }
private static void InputText(GameObject gameObject, string message) { InputField inputField = null; // Activate input field (set focus) AutotestingInternal.unityBinding.ExecuteOnMainThreadAndWaitForCompletion(() => { inputField = gameObject.GetComponent <InputField>(); if (inputField == null) { throw new ScriptException("InputText", $"No input field on the GameObject {gameObject.name}"); } inputField.ActivateInputField(); }); // Wait some frames to let Unity apply the focus on the inputField Thread.Sleep(3 * UnityBinding.frameDuration); // Set text, trigger onValueChanged and onEndEdit, then unfocus the component AutotestingInternal.unityBinding.ExecuteOnMainThreadAndWaitForCompletion(() => { inputField.text = message; inputField.DeactivateInputField(); }); }
private void SetConsoleActive(bool active) { if (active) { scrollrect.gameObject.SetActive(true); //Go ahead and reactivate this fella consoleCanvas.enabled = true; scrollrect.verticalNormalizedPosition = 0; inputField.ActivateInputField(); consoleAutocomplete.ResetAutocompleteIndex(); if (consoleActivationEvent != null) { consoleActivationEvent.Invoke(true); } } else { scrollrect.gameObject.SetActive(false); //Holy mother of God we can't allow this guy or it's children to update if it's not actually being shown consoleCanvas.enabled = false; inputField.text = ""; inputField.DeactivateInputField(); if (consoleActivationEvent != null) { consoleActivationEvent.Invoke(false); } } }
private void SetupInputHandling() { PIN1.onValueChanged.AddListener((string value) => { if (value.Length != 0) { PIN2.ActivateInputField(); } }); PIN2.onValueChanged.AddListener((string value) => { if (value.Length != 0) { PIN3.ActivateInputField(); } }); PIN3.onValueChanged.AddListener((string value) => { if (value.Length != 0) { PIN4.ActivateInputField(); } }); PIN4.onValueChanged.AddListener((string value) => { if (value.Length != 0) { PIN4.DeactivateInputField(); ComparePIN(); } }); }
/// 检测输入到4位 /// </summary> /// <param name="value"></param> async void CodeInput(string value) { if (HttpManager.Instance.IsConnectNet() == false) { UIManager.Instance.SystemDialog("您没有联网", 500); return; } if (value.Length == 4) { Debug.Log("发送验证码请求"); WWWForm www = new WWWForm(); www.AddField("phoneNumber", UserInformation.Instance.phoneNumber); www.AddField("code", inputCodeText.text); bool b = await HttpManager.Instance.Login(www); if (b) { inputCodeText.DeactivateInputField(); canvasgroup.blocksRaycasts = false; UIManager.Instance.PopAllPanel(); UIManager.Instance.PushPanel("Page_Main", UIFramework.Animation.rightToleft, 0.2f); UIManager.Instance.SystemDialog("登陆成功", 500); } else { Debug.Log(b); } } }
private void Awake() { m_throttleInput.text = "0"; rect = GetComponent <RectTransform>(); m_throttleInput.onValidateInput += delegate(string input, int charIndex, char addedChar) { return(ValidateThrottleInputChar(addedChar)); }; m_throttleInput.onEndEdit.AddListener(delegate { ValidateThrottle(m_throttleInput.text); infoWindowInterface.SetInputLock(false); m_throttleInput.DeactivateInputField(); m_throttleSlider.value = float.Parse(m_throttleInput.text); infoWindowInterface.ThrottleVisible = true; }); m_throttleSlider.onValueChanged.AddListener(delegate { if (m_throttleSlider.value != float.Parse(m_throttleInput.text)) { UpdateInputField(m_throttleSlider.value); } UpdatePersistentThrottle(m_throttleSlider.value); }); }
IEnumerator Kill() { input.DeactivateInputField(); yield return(new WaitForSeconds(0.8f)); isAlive = false; }
public void SetFocus(bool bFocus) { #if (UNITY_IOS || UNITY_ANDROID) && !UNITY_EDITOR if (!bNativeEditCreated) { focusOnCreate = bFocus; return; } JsonObject jsonMsg = new JsonObject(); jsonMsg["msg"] = MSG_SET_FOCUS; jsonMsg["isFocus"] = bFocus; this.SendPluginMsg(jsonMsg); #else if (gameObject.activeInHierarchy) { if (bFocus) { objUnityInput.ActivateInputField(); } else { objUnityInput.DeactivateInputField(); } } else { focusOnCreate = bFocus; } #endif }
/// <summary> /// Invoked, when user submits a message /// </summary> public virtual void OnSendClick() { var text = InputField.text; if (string.IsNullOrEmpty(text)) { return; } if (text[0] == '/') { HandleCommand(text); } else { HandleLocalMessage(text); } InputField.text = ""; InputField.DeactivateInputField(); // Workaround for not restoring focus instantly after sending a message with // "Return" key if (_allowFocusOnEnter) { StartCoroutine(DontAllowFocusOnEnter()); } }