private static void TMPInputFromInput(InputHandler handler) { if (handler == null) { return; } InputField input = handler.GetComponent <InputField>(); if (input == null) { return; } int limit = input.characterLimit; TMP_InputField.ContentType content = GetTMPContentType(input.contentType); float caretBlinkRate = input.caretBlinkRate; int caretWidth = input.caretWidth; Color selectionColor = input.selectionColor; GameObject obj = input.gameObject; RectTransform viewport = handler.GetComponentInChildren <RectMask2D>().rectTransform; Tracking_TMP placholder = handler.GetComponentsInChildren <Tracking_TMP>()[0]; Tracking_TMP textComponent = handler.GetComponentsInChildren <Tracking_TMP>()[1]; if (viewport == null || placholder == null || textComponent == null) { return; } DestroyImmediate(input); Tracking_TMP_Input tmp = obj.AddComponent <Tracking_TMP_Input>(); tmp.textViewport = viewport; tmp.placeholder = placholder; tmp.textComponent = textComponent; tmp.characterLimit = limit; tmp.contentType = content; tmp.caretBlinkRate = caretBlinkRate; tmp.caretWidth = caretWidth; tmp.selectionColor = selectionColor; tmp.readOnly = false; tmp.shouldHideMobileInput = false; tmp.fontAsset = UISkinManager.TMPFont; }
private void TMProFromText(TextHandler handler) { if (handler == null) { return; } Text text = handler.GetComponent <Text>(); if (text == null) { return; } string t = text.text; Color c = text.color; int i = text.fontSize; bool r = text.raycastTarget; FontStyles sty = TMPProUtil.FontStyle(text.fontStyle); TextAlignmentOptions align = TMPProUtil.TextAlignment(text.alignment); float spacing = text.lineSpacing; GameObject obj = text.gameObject; DestroyImmediate(text); Tracking_TMP tmp = obj.AddComponent <Tracking_TMP>(); tmp.text = t; tmp.color = c; tmp.fontSize = i; tmp.raycastTarget = r; tmp.alignment = align; tmp.fontStyle = sty; tmp.lineSpacing = spacing; tmp.font = UISkinManager.TMPFont; tmp.fontSharedMaterial = Resources.Load("Fonts/Materials/Calibri Dropshadow", typeof(Material)) as Material; tmp.enableWordWrapping = false; tmp.overflowMode = TextOverflowModes.Ellipsis; tmp.isOverlay = false; tmp.richText = true; }