How to replace Button Text when clicking another button?


I’m using Unity 4.6 and new to both Unity and c#.

How would I go about replacing the text within a button with the text from another button?

Say I have 5 buttons, the first button would be the main one that gets updated. I would like the text within that button to be replaced with the text from whichever other button the user clicks. So if I were to click Button 4 that says Fish, Button 1 would then also say Fish. Then if i were to click a different button it would update again to the text of the last button clicked. Example below.

  • Button 1: TempText
  • Button 2: Dog
  • Button 3: Bird
  • Button 4: Fish
  • Button 5: Bear

I’ve watched the tutorials and read other Unity answers on how to do this with the score, but as I’m new to this I’m not sure how to adapt it to work with clicking on a button to update another button. Would someone be kind enough to link me to a tutorial that explains how to do this or maybe provide example c# code?

Thank you for your time and assistance. I apologize ahead of time if there is a resource explaining exactly this, I haven’t had luck finding it.

  1. Select your “Dog” button and add OnClick event:

  2. Drop your TextObject to it: