Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by bryanllanes · Aug 12, 2017 at 11:10 PM · buttontextimagereplacequiz

Quiz Game: How to replace Text with Images?

So, I followed an official Unity tutorial about making a Quiz Game. I successfully followed each and every step and it works great. Now I want to replace the text on the buttons with images. I tried dragging one of the images into the button UI but it ends up changing all of it instead of just one single button. So how do I replace the text with an image on a button?

TUTORIAL LINK: http://www.unity3d.com/learn/tutorials/topics/scripting/quiz-game-intro-and-setup

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by rrabi · Aug 13, 2017 at 12:23 AM

@bryanllanes its because there is probably one or few button elements used to create all the choices, so buttons text is being changed at the runtime through code. look in the code where he sets the text of the buttons. when you find. instead of text start replacing with the images you want to set. if you need help with changing the image through code let me know.

Comment
Add comment · Show 9 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hiro12a · Aug 13, 2017 at 11:13 PM 0
Share

I need help with changing the image through code please.....I have searched for clues for days and still unable to find it....It would be really helpful if you could write the code or give out hints on applying it throughout the script

avatar image rrabi hiro12a · Aug 14, 2017 at 02:12 AM 1
Share

okay i looked through the scripts in the tutorial. i will give you a hint. in your AnswerData class change

     public string answerText;
 to 
 public Sprite answer

in your AnswerButton class. Change

  public Text answerText;

to

 public Image answer;

now change the Setup function to

  public void Setup(AnswerData data)
     {
         answerData = data;
         answer.sprite = answerData.answer;
     }

now your image changing code will work. you will receive some errors after these changes which will help you that where else do you need the change the text types to images/sprites.

avatar image hiro12a rrabi · Aug 14, 2017 at 02:19 AM 0
Share

.....it looks very simple.....Thank you, I will try it out

Show more comments
avatar image capstone02project · Aug 20, 2018 at 08:36 PM 0
Share

I follow all you say but the button is not changing. I even change the text to image but when i run i always see is a single button without an image that i put. Plsss answer what the other that i need to change?

avatar image thejrz12 capstone02project · Sep 03, 2018 at 07:48 AM 0
Share

Sir we have the same problem. What did you do? can't find any clue from the internet since i'm beginner in program$$anonymous$$g.

avatar image
0

Answer by anthonygonzalez · Aug 17, 2017 at 03:22 AM

When I change it to factText.sprite, currentQuestion.vraag gives an error that says “Cannot implicitly convert type ‘UnityEngine.UI.Image’ to ‘UnityEngine.sprite’.”

 [System.Serializable]
 public class Questions {
  public string fact;
  public string answerOne;
  public string answerTwo;
  public string answerThree;
  public string answerFour;
  public bool isOne;
  public bool isTwo;
  public bool isThree;
  public bool isFour;
 }

This is the one that’s used for the text one.

 using UnityEngine.UI;
 [System.Serializable]
 public class ImageVragen
 {
  public Image vraag;
  public Image antwoord1;
  public Image antwoord2;
  public Image antwoord3;
  public Image antwoord4;
  public bool isOne;
  public bool isTwo;
  public bool isThree;
  public bool isFour;
 }

And this is the one that is used for the image one

(also thank you for trying to help me so far, much appreciated)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

86 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to change button image on click 2 Answers

How to understand if 4.6 UI button is highlighted? 3 Answers

Buttons become invisible when changing color (on Button or on Image) in script -1 Answers

Display a float number when button is clicked 4 Answers

initiate Imagebuttons in loop 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges