public void ReplaceInputFieldWithTMPro(InputField field, UnityAction <string> onSubmit = null, UnityAction <string> onChange = null) { var text = GUIComponentManager.ReplaceTextWithTMPro(field.textComponent); Graphic placeholder = field.placeholder; if (placeholder is Text) { placeholder = GUIComponentManager.ReplaceTextWithTMPro(placeholder as Text); } var contentType = field.contentType; var lineType = field.lineType; var charLimit = field.characterLimit; var interactable = field.interactable; var go = field.gameObject; UnityEngine.Object.DestroyImmediate(field); inputField = go.AddOrGetComponent <TMPro.TMP_InputField> (); inputField.textComponent = text; inputField.textViewport = text.transform as RectTransform; inputField.placeholder = placeholder; if (onSubmit != null) { inputField.onEndEdit.AddListener(onSubmit); } if (onChange != null) { inputField.onValueChanged.AddListener(onChange); } inputField.contentType = (TMPro.TMP_InputField.ContentType)contentType; inputField.lineType = (TMPro.TMP_InputField.LineType)lineType; inputField.characterLimit = charLimit; inputField.interactable = interactable; }
public UnityAction <string> ReplaceTextComponentWithTMPro(Text text) { var ugui = GUIComponentManager.ReplaceTextWithTMPro(text); return(ugui.SetText); }