public void Rebuild() { if (input.textComponent.enabled && checker.NeedRebuild()) { //================================ // fix bug for tmp // TMPの不具合で、正しく座標を設定されてなかったため、試しに対応する var rt = input.textComponent.GetComponent <RectTransform>(); var size = input.textComponent.GetPreferredValues(); if (size.x < rt.rect.xMax) { // textComponent の座標を更新 var pos = rt.anchoredPosition; pos.x = 0; rt.anchoredPosition = pos; // caret の座標更新 var caret = input.GetComponentInChildren <TMP_SelectionCaret>(); var caretRect = caret.GetComponent <RectTransform>(); caretRect.anchoredPosition = rt.anchoredPosition; } //============================== // HACK : 1フレーム無効にする // MEMO : 他にいい方法Rebuildがあれば対応する // LayoutRebuilder.ForceRebuildLayoutImmediate(); で試してダメでした input.textComponent.enabled = false; input.Rebuild(CanvasUpdate.LatePreRender); input.textComponent.SetAllDirty(); } else { input.textComponent.enabled = true; } }
public void UpdateMapSelectionInput() { LoadToFile(); mapSelectionInput.GetComponentInChildren <TextMeshProUGUI>().text = mapSelectionInput.text; try { mapNameInput.text = mapSelectionInput.text; mapNameInput.GetComponentInChildren <TextMeshProUGUI>().text = mapSelectionInput.text; } catch { //do nothing - if you don't interact with the mapNameInput before hand it errors out saying that the //object does not exist, but it does exist and functions as intended. I do not know why I get this error. } }
void Awake() { inputFieldRT = inputField.GetComponent <RectTransform>(); inputFieldTM = inputField.GetComponentInChildren <TextMeshProUGUI>(); }
// Start is called before the first frame update void Start() { userString = codeField.GetComponentInChildren <TextMeshProUGUI>(); }