- Home /
Question by
satish004004 · Aug 15, 2019 at 05:09 PM ·
buttongameimages
How To Change a Image When Press Button Click?
I M Making 2D Game.
Link : https://www.youtube.com/watch?v=CXwQhQ0XL1g&feature=youtu.be
Flow
canvas
Panel(RockPaperSoccerScript.cs)
Image(Image component) (I want to change this image when i press first button click or second buttonclick or third buttonclick)
FirstImage(Image component and ButtonComponent(FirstImageButtonClick())
SecondImage(Image component and ButtonComponent(SecondImageButtonClick())
ThirdImage(Image Component and ButtonComponent)(ThirdImageButton())
Code:
RockPaperSoccerScript.cs
public GameObject mainimagegameobject; //I want to change this image
public List<GameObject> mylistgameobject = new List<GameObject>(); //Store the first image component, second image component, third image component
public void FirstImageButtonClick()
{
mainimagegameobject = mylistgameobject[0];
Debug.Log("inside first button image click");
}
public void SecondImageButtonClick()
{
mainimagegameobject = mylistgameobject[1];
Debug.Log("inside second button image click");
}
public void ThirdImageButton()
{
mainimagegameobject = mylistgameobject[2];
Debug.Log("inside third button image click");
}
rps.png
(103.8 kB)
buttonrps.png
(45.1 kB)
Comment
Your answer
Follow this Question
Related Questions
i want to create a small game 1 Answer
swap images using 2 buttons(next, previous) 0 Answers
android, button help 1 Answer
How to cover buttons with game objects? 1 Answer
How do I put a "Rate game" button? 6 Answers