Unity UI Tutorial: Set Text On Button Click C# Event

preview_player
Показать описание
I had a request to create a Unity tutorial on how to set a text for a UI Text field when a button is clicked. I show in this show video how to create this simple UI in a Unity scene and then I implement the C# script for the button to set the text for a text field.

The text field can be dragged to a public variable of type UnityEngine.UI.Text and I bind the On clicked event of the button to a public method that I implemented called SetText of the script.

See my social profiles here:

Рекомендации по теме
Комментарии
Автор

How do I make the text change back to what it was earlier after clicking on the button a second time?

barkhaseth
Автор

Thank you so much, thats exactly what i needed.

nerokuma
Автор

Bro I need help, actually there is one issue I am facing with the appearance of text in unity, its like a notification text which I have created and just want it to appear when it should and it does appear in the text input box after hitting play but we have to manually disable and enable it then only it shows on UI and then once you exit it goes back ! can't understand what's the issue !

akhilmishra
Автор

Trying to make a conversation, how can I get it to prompt more text after this?

parrymegundyr
Автор

Is there a way to do that with inputField?

kingclassic
Автор

That doesn't show up for me while typing, not sure how we're supposed to follow along without that

HughMongousPC
Автор

Hello, how can I set the text from a list of quotes randomly to show instead of Mt text ?

pauldurand
Автор

Why mine doesn't change in the game scene but the contents of the text change when I view in the inspector.

realamp
Автор

lol that Diablo backgroung music tho...

soma
Автор

Hi your vid is very useful but can you make a tutorial on how to change what to click to show the message? I want it to be after interacting with an object by pressing "E", then it shows a message. How can I do that? Thanks!!!

KaLeeLIU-zdeh
Автор

This video is a weapon of mass destruction. Your use of the word "text" to name different elements or properties is brain-breaking and confusing - it prevents the lesson from landing. Very confusing.

johnjoseph
Автор

useless and overly complicated, comedy shop as most youtube unity videos

JJ-fqdh