- Home /
Adding Images to Prefabs,Adding Images to prefab
Hello together,
i got the following Problem:
We use button prefab for our UI elements. However, we now want to add a image field to the prefab, that we could later use to show a thumbail of objects.
Im not sure if you can do anything with it, when i just post the prefab as is here, but you can find the prefab we use here: https://pastebin.com/bL379YFd
We now have troubles, to edit the prefab, so that a Image can be shown next to the buttons label.
So the steps we tried:
"Instantiate" the prefab by dragging it in the Scene.
Add a "UI -> Image" to the Scene
Drag the Image to the Button, so that it is the parent of the Image.
Set the Texture of the image to actually see something.
And this is the part we having the troubles. We cannot get any image to show on the Button :(
What are we actually doing wrong, can anyone point this out to us?
I will fill the Question with Pictures later, to clarify what we are doing. Just cant do it now, since i don't have direct access to a Unity instance right now.
Try setting the RectTransform of the image to fill the area of the Button: click on the rectangular icon in the RectTransform, select the bottom right option to match anchors to parent, and then set all the 4 values (left, top, right, bottom) to 0.
Sadly, this didn't help.
Is there any more information i can give so we could work this out?
I don't have any idea other than to make the image the same size as the parent button object. Stupid question, but to make sure, the texture is set to be a sprite, right?
Otherwise, could you post screenshots of the settings of the Button and the Image? $$anonymous$$aybe that will help. Btw, this is what I've meant how to set up the RectTransform of the Image: