update text label when button is clicked

hi folks,

I’m looking to put together a little learning app using Unity 5. At first, I thought it would be simple but turns out, I’m still looking for an answer. The training video from unity on UI.TEXT was only 3 mins long and didn’t help.

basically, I have a text label that starts out with “1 - One”. When the “next” button is pressed, I want it to call a function that takes an int and increment by 1. In that function, it would contain the case statement needed to display my text based on the int value. My problem is how do I link that to the text label?

Thanks.

You may want to look through some of the scripting learn tutorials - http://unity3d.com/learn/tutorials/topics/scripting
Essentially you want to hold a reference to the UI Text component within your script. You can then set/get its text value by calling the text property.

hey karl.jones.

I read those document but I was looking for some sort of example. But after spending the last 3 days looking for an answer, I accidentally found the solution on my own. I was attaching the script to PlayerControl and not my NumberLabel text object. PlayerControl was just an empty gameObject.

Can you tell me how to fix the pixilation in the text? I feel like I’m looking at 8bit minecraft style text.

2250132--150349--1-one.PNG

Thanks.

Did you scale up the text? Scale it back down and increase the font size instead. If your text vanishes then set vertical overflow to Overflow or increase the rectangle so it fits.

Thanks karl. That did the trick.