I have a canvas to which I have added a raw image.
How can I get a background image from code?
I have this code that reads some folders and looks for where the image is.
private void LoadBgImage() {
string RuteBackground = Application.dataPath + "/StreamingAssets/ImgBackground";
string[] files = Directory.GetFiles(RuteBackground);
string background = files.FirstOrDefault(s => s.EndsWith(".jpg") || s.EndsWith(".png"));
}
In background I keep the path of the image.
How do I assign it to the raw image of the canvas?