[solved]accessing text boxes' text field in code

here’s what i tried, with the help of someone on IRC: https://hastebin.com/iferuvezoc.cs

i dragged the script into the text box, and then dragged the text box into the myText field. unfortunately, no numbers are displayed in the text field when i run the game and press the buttons.

can i use get component somehow? what should i do? or can i get the text field to work somehow? if you need to see more code i can show you my AbilityPointbuySet script but this shouldn’t be necessary.

I’d say double check that the methods are being run (insert debug.log with the Globals.abilities[1].ToString(“G”) if needed to see if you are getting what you expect) and then if it is, select the item in the inspector to see if the text is even being added to the text field. If you see the text, make sure your textbox is big enough to show the text, else it isn’t going to display.

so what i described doing, dragging the script into the text box, and then the text box itself into the myText field - that should work? i don’t need to do something with get component or another method?

If you add a Text object into your scene. It should be under a canvas( I assume you have this since you said you had buttons). The script you showed can be anywhere since you are adding the text box into the variable by dragging and dropping it, then you are fine. There is no need to use getComponent since you already have the reference to the text box through the drag and drop in inspector.

https://hastebin.com/bumayovefo.cs

what’s wrong with this code? i associated the buttons (up and down buttons for each attribute) with the appropriate methods and then i dragged the appropriate text box into the text field for each text box. still not working…

edit: got it working, sort of! i think there are just some logical errors making my ability setting gui not work completely right. that’s easy to fix though.

i used:
Text text;
text = GameObject.Find(“Text (4)”).GetComponent();
text.text = Globals.abilities[0].ToString(“G”);

you get the idea. hope this helps someone in the future get unstuck.