- Home /
How to change RawImage texture to another one when i press a buton for it
Hi all, i am new to unity and i am stuck about this problem. I need to change texture od RawImage with second image with a press of a button. I am basicly trying to create to people chose about different item that would be in 2d game. I would like to create other scene that would have a different images of items and when i click on one of them it change the RawImage texture in game scene. I would really aprecitate any idea and help. Thank you in advance.
Answer by myzzie · Jan 16, 2018 at 05:41 PM
public GameObject imageDisplay; //Gameobject with rawImage
public Texture image; //Reference to a preset image
public void DisplayImage(Texture texture)
{
imageDisplay.GetComponent<RawImage>().texture = texture; //Set texture to either image or a texture set in the button's onClick ui
}
There are many ways to do this. but that's one way to change texture of a rawimage
Your answer
Follow this Question
Related Questions
Image for button programmatically 1 Answer
GUI button doesn't appear on Android 0 Answers
Passing texture to android plugin 0 Answers
Save a Texture2D for android 1 Answer