Hello. I have an issue that has been bugging me for a while now. First, what I want to do: We want to change the picture of one RawImage component depending on what map is picked from a Dropdown menu that is called MapSelect which has options on it. I have tried everything that I can to change the image on MapPicture including trying to change its sprite texture with if (MapSelect.GetComponent().value == 0) { MapPicture.GetComponent().sprite = RandomPicture; } (if they haven’t selected anything yet) this gave me an error so I tried this paired with a RawImage on the MapPicture GameObject instead of an Image property (yes, I did have the picture as a Sprite 2D and UI) and I declared the MapPicture as a RawImage and I set the RandomPicture as a Texture paired with this line of code: if (MapSelect.GetComponent().value == 0) { MapPicture.GetComponent().texture = RandomPicture; } and it doesn’t give me an error. I think it might just be the way I’m setting up the if statement that is checking the value of MapSelect because I had previously put a print() statement within these and it didn’t even run. I just have no idea what is going wrong. Thank you for the help.
This works for me:
Convert texture to appropriate derived class and call Apply method
public RawImage rawImage;
rawImage.texture = ScreenCapture.CaptureScreenshotAsTexture();
(rawImage.texture as Texture2D).Apply();
@IgorSimovic I just tried doing it this way and was getting an error on it so I looked at the documentation and in the most recent version of Unity this was removed. Do you have any other way of solving it perhaps? Thank you.