- Home /
Question by
ccd01455 · Feb 19 at 10:12 PM ·
scripting problemgetcomponent
How to assign an image to an object at level 2
Hi,
On the image below, I would like to assign puzzleImage to the btn image on level 2. I tried a lot of things but nothing works. I'm beginning my first video game.
Somebody can help me?
Regards!
Robert
howtoassign.png
(81.4 kB)
howtoassign.png
(81.4 kB)
Comment
Answer by ccd01455 · Feb 20 at 07:39 PM
I finally succeed.
I've added a [serializedfield] Transform puzzleMenuSelectPanel; To use Find you need a Transform object.
Then I have defined the path and assign the image: puzzleMenuSelectPanel.Find("Puzzle Game Panel " + (level + 1) + "/Puzzle Buttons Holder " + (level + 1) + "/" + btn.name + "/CardFront/Image").GetComponent().sprite = puzzleImage;