public override bool Perform(bool repeat = false) { TMPro.TMP_InputField inputField = StaticAction.GetSelectedInputField(); if (!!inputField) { inputField.caretPosition = Mathf.Max(inputField.caretPosition - 1, 0); return(true); } return(false); }
public override bool Perform(bool repeat = false) { TMPro.TMP_InputField inputField = StaticAction.GetSelectedInputField(); if (!!inputField) { inputField.MoveTextStart(false); return(true); } return(false); }
public override bool KeyCallback(InputEvent eventMask, char _, KeyCode __, EventModifiers eventModifiers) { TMPro.TMP_InputField inputField = StaticAction.GetSelectedInputField(); if (!!inputField) { inputField.caretPosition = Mathf.Max(inputField.caretPosition - 1, 0); return(true); } return(false); }
public override bool KeyCallback(InputEvent eventMask, char _, KeyCode __, EventModifiers eventModifiers) { TMPro.TMP_InputField inputField = StaticAction.GetSelectedInputField(); if (!!inputField) { inputField.MoveTextStart((eventModifiers & EventModifiers.Shift) != 0); return(true); } return(false); }
public override bool Perform(bool repeat = false) { TMPro.TMP_InputField inputField = StaticAction.GetSelectedInputField(); if (!!inputField) { inputField.selectionStringAnchorPosition = 0; inputField.selectionStringFocusPosition = inputField.text.Length; return(true); } return(false); }
private void OnEnable() { if (inputObj == null) { inputObj = GetComponent <TMPro.TMP_InputField>(); } if (inputObj == null && CheckDeprecated(gameObject)) { deprecatedObject = gameObject; } }
public static string CutSelection(TMPro.TMP_InputField inputField) { int startPosition, endPosition; string selection = GetSelectionpublic(inputField, out startPosition, out endPosition); if (!string.IsNullOrEmpty(selection)) { inputField.text = inputField.text.Remove(startPosition, endPosition - startPosition); inputField.selectionStringFocusPosition = inputField.selectionStringAnchorPosition = startPosition; } return(selection); }
static StackObject *get_text_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); TMPro.TMP_InputField instance_of_this_method = (TMPro.TMP_InputField) typeof(TMPro.TMP_InputField).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.text; return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
// Start is called before the first frame update void Start() { if (!m_inputField) { m_inputField = GetComponent <TMPro.TMP_InputField>(); } YoutubePlayer.OnDownloading -= () => { m_inputField.interactable = false; }; YoutubePlayer.OnEndDownload -= () => { m_inputField.interactable = true; }; YoutubePlayer.OnAudioExtracting -= () => { m_inputField.interactable = false; }; YoutubePlayer.OnEndAudioExtracting -= () => { m_inputField.interactable = true; }; }
/// <summary> /// Call the external javascript function to trigger the keyboard and link to the input field /// </summary> /// <param name="input"></param> public void FocusInput(TMPro.TMP_InputField input) { isKeyboardOpen = true; currentTmproInput = input; #if UNITY_EDITOR Debug.Log("OpenInputKeyboard"); #else OpenInputKeyboard(input.text); #endif #if !UNITY_EDITOR && UNITY_WEBGL UnityEngine.WebGLInput.captureAllKeyboardInput = false; #endif }
/// <summary> /// Apply style to the specified slider. /// </summary> /// <param name="component">Slider.</param> public virtual void ApplyTo(TMPro.TMP_InputField component) { if (component == null) { return; } Background.ApplyTo(component); Text.ApplyTo(component.textComponent.gameObject); if (component.placeholder != null) { Placeholder.ApplyTo(component.placeholder.gameObject); } }
void Start() { var validators = FindObjectsOfType <UpgradeValidator>(); foreach (var val in validators) { var newPrefab = Instantiate(Prefab, LayoutParent); newPrefab.SetTarget(val); } StatResetButton.onClick.AddListener(SetPlayerStatsToHalf); _inputField = StatResetButton.GetComponentInChildren <TMPro.TMP_InputField>(); _child = transform.GetChild(0).gameObject; ChangeState(false); }
/// <summary> /// MonoBehaviour method called on GameObject by Unity during initialization phase. /// </summary> void Start() { string defaultName = string.Empty; TMPro.TMP_InputField _inputField = this.GetComponent <TMPro.TMP_InputField>(); if (_inputField != null) { if (PlayerPrefs.HasKey(playerNamePrefKey)) { defaultName = PlayerPrefs.GetString(playerNamePrefKey); _inputField.text = defaultName; } } PhotonNetwork.NickName = defaultName; }
static StackObject *set_text_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.String @value = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); TMPro.TMP_InputField instance_of_this_method = (TMPro.TMP_InputField) typeof(TMPro.TMP_InputField).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); __intp.Free(ptr_of_this_method); instance_of_this_method.text = value; return(__ret); }
public override bool Perform(bool repeat = false) { TMPro.TMP_InputField inputField = StaticAction.GetSelectedInputField(); if (!inputField) { return(false); } var selectedString = StringHelper.GetSelection(inputField); if (selectedString == null) { return(false); } GUIUtility.systemCopyBuffer = selectedString; return(true); }
/// <summary> /// Starts the client using an input field to determine the URI /// </summary> /// <param name="inputField"></param> public void StartClient(TMPro.TMP_InputField inputField) { UriBuilder uriBuilder = new UriBuilder(); uriBuilder.Scheme = "tcp4"; if (IPAddress.TryParse(inputField.text, out IPAddress address)) { uriBuilder.Host = address.ToString(); } else { uriBuilder.Host = "localhost"; } var uri = new Uri(uriBuilder.ToString(), UriKind.Absolute); StartClient(uri); }
public void Apply_Internal(TMPro.TMP_InputField input) { if (input != null) { input.text = m_Text; input.inputType = (TMPro.TMP_InputField.InputType)Enum.ToObject(typeof(TMPro.TMP_InputField.InputType), (int)m_InputType); input.lineType = (TMPro.TMP_InputField.LineType)Enum.ToObject(typeof(TMPro.TMP_InputField.LineType), (int)m_LineType); input.contentType = (TMPro.TMP_InputField.ContentType)Enum.ToObject(typeof(TMPro.TMP_InputField.ContentType), (int)m_ContentType); input.characterValidation = (TMPro.TMP_InputField.CharacterValidation)Enum.Parse(typeof(TMPro.TMP_InputField.CharacterValidation), Enum.GetName(typeof(InputField.CharacterValidation), m_ContentType)); input.keyboardType = m_KeyboardType; input.characterLimit = m_CharacterLimit; input.asteriskChar = m_AsteriskChar; input.shouldHideMobileInput = m_HideMobileInput; if (input.placeholder != null) { input.placeholder.SetGraphicText(m_HintText); } } }
public ModInputField() { gameObject = new UnityEngine.GameObject("Input Field"); rectTransform = gameObject.AddComponent <RectTransform>(); GameObject inputField = TMPro.TMP_DefaultControls.CreateInputField(new TMPro.TMP_DefaultControls.Resources { }); inputField.transform.SetParent(rectTransform); RectTransform inputRect = inputField.GetComponent <RectTransform>(); inputRect.anchorMin = new Vector2(0, 1); inputRect.anchorMax = new Vector2(0, 1); inputRect.pivot = new Vector2(0, 1); inputRect.sizeDelta = new Vector2(320, 48); tmpInputField = inputField.GetComponent <TMPro.TMP_InputField>(); tmpInputField.pointSize = 30; }
private static string GetSelectionpublic(TMPro.TMP_InputField inputField, out int startPosition, out int endPosition) { startPosition = inputField.selectionStringAnchorPosition; endPosition = inputField.selectionStringFocusPosition; if (startPosition > endPosition) { int tmpPosition = startPosition; startPosition = endPosition; endPosition = tmpPosition; } else if (startPosition == endPosition) { return(null); // no selection found // } var selectedString = inputField.text.Substring(startPosition, endPosition - startPosition); return(Regex.Replace(selectedString, @"<[^>]*>", string.Empty)); }
/// <summary> /// True if any input element is active. /// </summary> /// <returns></returns> public static bool IsInputInUse() { GameObject selected = EventSystem.current.currentSelectedGameObject; if (selected != null) { UnityEngine.UI.InputField inputField = selected.GetComponent <UnityEngine.UI.InputField>(); if (inputField != null) { return(true); } TMPro.TMP_InputField tmpInputField = selected.GetComponent <TMPro.TMP_InputField>(); if (tmpInputField != null) { return(true); } } return(false); }
public override void ShowGUI(Menu menu) { string apiPrefix = "(AC.PlayerMenus.GetElementWithName (\"" + menu.title + "\", \"" + title + "\") as AC.MenuInput)"; MenuSource source = menu.menuSource; CustomGUILayout.BeginVertical(); if (source == MenuSource.AdventureCreator) { inputType = (AC_InputType)CustomGUILayout.EnumPopup("Input type:", inputType, apiPrefix + ".inputType", "What kind of characters can be entered in by the player"); label = EditorGUILayout.TextField("Default text:", label); if (inputType == AC_InputType.AlphaNumeric) { allowSpaces = CustomGUILayout.Toggle("Allow spaces?", allowSpaces, apiPrefix + ".allowSpace", "If True, then spaces are recognised"); } else if (inputType == AC_InputType.NumbericOnly) { allowDecimals = CustomGUILayout.Toggle("Allow decimals?", allowDecimals, apiPrefix + ".allowDecimals", "If True, then decimals are recognised"); } characterLimit = CustomGUILayout.IntField("Character limit:", characterLimit, apiPrefix + ".characterLimit", "The character limit on text that can be entered"); #if (UNITY_IPHONE || UNITY_ANDROID) && !UNITY_2018_3_OR_NEWER EditorGUILayout.HelpBox("For the character limit to be obeyed on Android and iOS, Unity 2018.3 or later must be used.", MessageType.Info); #endif linkedButton = CustomGUILayout.TextField("'Enter' key's linked Button:", linkedButton, apiPrefix + ".linkedPrefab", "The name of the MenuButton element that is synced with the 'Return' key when this element is active"); requireSelection = CustomGUILayout.ToggleLeft("Require selection to accept input?", requireSelection, apiPrefix + ".requireSelection", "If True, then the element will need to be selected before it receives input"); } else { #if TextMeshProIsPresent uiInput = LinkedUiGUI <TMPro.TMP_InputField> (uiInput, "Linked InputField:", source); #else uiInput = LinkedUiGUI <InputField> (uiInput, "Linked InputField:", source); #endif uiSelectableHideStyle = (UISelectableHideStyle)CustomGUILayout.EnumPopup("When invisible:", uiSelectableHideStyle, apiPrefix + ".uiSelectableHideStyle", "The method by which this element is hidden from view when made invisible"); } CustomGUILayout.EndVertical(); base.ShowGUI(menu); }
/** * Initialises the element when it is created within MenuManager. */ public override void Declare() { uiInput = null; label = "Input"; isVisible = true; isClickable = true; numSlots = 1; anchor = TextAnchor.MiddleCenter; SetSize(new Vector2(10f, 5f)); inputType = AC_InputType.AlphaNumeric; characterLimit = 10; linkedButton = string.Empty; textEffects = TextEffects.None; outlineSize = 2f; allowSpaces = false; uiSelectableHideStyle = UISelectableHideStyle.DisableObject; requireSelection = false; allowDecimals = false; base.Declare(); }
public override void Start() { base.Start(); commandInputText = GetComponentInChildren<TMPro.TMP_InputField>(); DisplayPanelListener = new System.Action<bool>((activate) => { if (activate) { Children[0].color = Inactive; commandInputText.text = displayText; } else { Children[0].color = Active; commandInputText.text = emptyStr; } }); EventManager.StartListening(EventManager.displayPanelToggle + transform.parent.name, DisplayPanelListener); GenerateActivationEvent(PasswordInputPanelListener, EventManager.passwordPanelToggle, false); }
public IEnumerator TestOnClickEvent() { yield return(InputTextCreate()); //------------------------------------------------------------------------ // Test click events TMPro.TMP_InputField inputField = textInput.referencesContainer.inputField; string targetEventType = "SceneEvent"; var onClickEvent = new WebInterface.OnClickEvent(); onClickEvent.uuid = textInput.model.onClick; var sceneEvent = new WebInterface.SceneEvent <WebInterface.OnClickEvent>(); sceneEvent.sceneId = scene.sceneData.id; sceneEvent.payload = onClickEvent; sceneEvent.eventType = "uuidEvent"; string eventJSON = JsonUtility.ToJson(sceneEvent); bool eventTriggered = false; yield return(TestHelpers.WaitForMessageFromEngine(targetEventType, eventJSON, () => { UnityEngine.EventSystems.EventSystem.current.SetSelectedGameObject(inputField.gameObject, null); inputField.ActivateInputField(); inputField.Select(); }, () => { eventTriggered = true; })); yield return(null); Assert.IsTrue(eventTriggered); }
/// <summary> /// Targets the indicated input field for the keyboard. This will also 'select' the InputField in Unity UI /// </summary> /// <param name="target"></param> public void SetInputTarget(TMPro.TMP_InputField target) { if (!ValidateHost()) { return; } _tmpInputField = target; _inputField = null; if (_tmpInputField != null) { _tmpInputField.Select(); LastTMProInputField = _tmpInputField; if (_tmpInputField.selectionAnchorPosition > _tmpInputField.selectionFocusPosition) { insertPoint = _tmpInputField.selectionFocusPosition; selectionLength = _tmpInputField.selectionAnchorPosition - _tmpInputField.selectionFocusPosition; } else if (_tmpInputField.selectionFocusPosition > _tmpInputField.selectionAnchorPosition) { insertPoint = _tmpInputField.selectionAnchorPosition; selectionLength = _tmpInputField.selectionFocusPosition - _tmpInputField.selectionAnchorPosition; } else { insertPoint = _tmpInputField.selectionAnchorPosition; selectionLength = 0; } } if (_tmpInputField != null && EventSystem.current.currentSelectedGameObject != linkedGameObject) { LastTMProInputField = _tmpInputField; linkedGameObject = EventSystem.current.currentSelectedGameObject; linkedBehaviour = LastTMProInputField; field = "text"; } }
/// <summary> /// Targets the indicated input field for the keyboard. This will also 'select' the InputField in Unity UI /// </summary> /// <param name="target"></param> public void SetInputTarget(UnityEngine.UI.InputField target) { if (!ValidateHost()) { return; } _inputField = target; _tmpInputField = null; if (_inputField != null) { _inputField.Select(); lastInputField = _inputField; if (_inputField.selectionAnchorPosition > _inputField.selectionFocusPosition) { insertPoint = _inputField.selectionFocusPosition; selectionLength = _inputField.selectionAnchorPosition - _inputField.selectionFocusPosition; } else if (_inputField.selectionFocusPosition > _inputField.selectionAnchorPosition) { insertPoint = _inputField.selectionAnchorPosition; selectionLength = _inputField.selectionFocusPosition - _inputField.selectionAnchorPosition; } else { insertPoint = _inputField.selectionAnchorPosition; selectionLength = 0; } } if (_inputField != null && EventSystem.current.currentSelectedGameObject != linkedGameObject) { lastInputField = _inputField; linkedGameObject = EventSystem.current.currentSelectedGameObject; linkedBehaviour = lastInputField; field = "text"; } }
private void Awake() { hostInputField = GetComponent <TMPro.TMP_InputField>(); if (initalizeMode == UixSyncInitializationMode.MatchVariable && textVariable != null) { internalUpdate = true; hostInputField.text = textVariable.Value; internalUpdate = false; } else if (initalizeMode == UixSyncInitializationMode.MatchUiControl && textVariable != null) { internalUpdate = true; textVariable.Value = hostInputField.text; internalUpdate = false; } hostInputField.onValueChanged.AddListener(HandleChange); hostInputField.onEndEdit.AddListener(HandleEndEdit); }
public override bool Perform(bool repeat = false) { TMPro.TMP_InputField inputField = StaticAction.GetSelectedInputField(); if (!!inputField) { int startPosition = inputField.selectionStringAnchorPosition; int endPosition = inputField.selectionStringFocusPosition; if (startPosition > endPosition) { int tmpPosition = startPosition; startPosition = endPosition; endPosition = tmpPosition; } else if (startPosition == endPosition) { if (endPosition == inputField.text.Length) return true; endPosition++; } GUIUtility.systemCopyBuffer = inputField.text.Substring(startPosition, endPosition - startPosition); inputField.text = inputField.text.Remove(startPosition, endPosition - startPosition); inputField.selectionStringFocusPosition = inputField.selectionStringAnchorPosition = startPosition; return true; } return false; }
public ChannelMessageContextMenu CreateChannelMessageContextMenu(ChannelMessage channelMessage, TMPro.TMP_InputField inputField) { var gameManager = OpenTibiaUnity.GameManager; var canvas = gameManager.ActiveCanvas; var gameObject = Instantiate(gameManager.ContextMenuBasePrefab, canvas.transform); var channelMessageContextMenu = gameObject.AddComponent <ChannelMessageContextMenu>(); channelMessageContextMenu.Set(_activeChannel, channelMessage, inputField); return(channelMessageContextMenu); }
public UIInputField(TMPro.TMP_InputField textMeshProInputField) { this.uiInputField = null; this.textMeshProInputField = textMeshProInputField; }