Home Game Development unity – Caret not seen with TMP_InputField created from script

unity – Caret not seen with TMP_InputField created from script

0
unity – Caret not seen with TMP_InputField created from script

[ad_1]

I’m modding an Unity recreation. I haven’t got entry to its supply, to any Unity editor or belongings. All I’ve is BepInEx and a few C# scripting, plus no matter Visual Studio can decompile from dlls.

I create an TMP_InputField when the consumer presses Enter as follows:

var canvas = new GameObject("CommandConsoleCanvas");
var c = canvas.AddComponent<Canvas>();
c.renderMode = RenderMode.ScreenSpaceOverlay;

var inputField = new GameObject("CommandConsoleInput");
inputField.rework.dad or mum = canvas.rework;

var inputFieldText = inputField.AddComponent<TMP_InputField>();
var txt = inputField.AddComponent<TextMeshProUGUI>();
inputFieldText.textComponent = txt;

inputFieldText.fontAsset = fontAsset;
inputFieldText.pointSize = 20;
inputFieldText.textual content = "instance...";
inputFieldText.enabled = true;
inputFieldText.caretColor = Color.white;
inputFieldText.caretWidth = 4;
inputFieldText.choiceColor = Color.white;
inputFieldText.onFocusSelectAll = false;

var rect = inputField.GetComponent<RectTransform>();
rect.localPosition = new Vector3(0, 0, 0);
rect.sizeDelta = new Vector2(400, 25);

inputFieldText.Select();
inputFieldText.ActivateInputField();

This form of works. I can see the textual content and kind in. However, there is not any caret and no indication of the present choice.

How can I make the caret and present choice render?

There have to be some settings or elements I’m lacking however cannot determine it out through Googling and searching on the API.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here