private 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); TMP_InputField.LineType line = TMPProUtil.LineType(input.lineType); float caretBlinkRate = input.caretBlinkRate; int caretWidth = input.caretWidth; Color selectionColor = input.selectionColor; GameObject obj = input.gameObject; RectTransform viewport = handler.GetComponentInChildren <RectMask2D>().rectTransform; CWTextMeshPro placholder = handler.GetComponentsInChildren <CWTextMeshPro>()[0]; CWTextMeshPro textComponent = handler.GetComponentsInChildren <CWTextMeshPro>()[1]; if (viewport == null || placholder == null || textComponent == null) { return; } MonoBehaviour.DestroyImmediate(input); CWTextMeshProInput tmp = obj.AddComponent <CWTextMeshProInput>(); tmp.textViewport = viewport; tmp.placeholder = placholder; tmp.textComponent = textComponent; tmp.characterLimit = limit; tmp.contentType = content; tmp.lineType = line; 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; MonoBehaviour.DestroyImmediate(text); CWTextMeshPro tmp = obj.AddComponent <CWTextMeshPro>(); 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 = true; tmp.isOverlay = false; tmp.richText = true; tmp.Setup(handler); }