Image instead of Question text

Hello Guys. I am trying to put an image instead of text in the Question box.

I think I succeed before serializing fields using type SPRITE( and placing sprites instead of text in the questions)

But now I am in trouble. In this lesson is explicated how to make this thing

questionText.text

i created like

questionImage type Sprite

but I don’t know what to put there

questionImage.???

if I left it questionImage without dot anything, unity is expecting for something type sprite.

How to chain the Question place I choose for questionImage?

Good Luck!

Hi Alex,

What component do you use in the Unity editor to display the sprite? Have you looked that type up in the API? There should be a public field in the component to which you should be able to assign your sprite.

1 Like

Hello. I Already fixed it by myself. Thank you.

I found unity documentation.

So I added on the top
using UnityEngine.UI;

and
I serialized the image I need
[SerializeField] Image questionImage;
and I added Image in Unity

and in start method

questionImage.sprite = question.GetQuestion();

and it Works!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms