Any one know how I might be able to let a user select a background image of their own for a panel or canvas?
This really depends on the platform you target.
Anyway, you’ll have to go with a RawImage, as it uses a Texture2D, which can be loaded at runtime.
Texture2D can be loaded from StreamingAssets Path for example, or from the user documents folder.
If you want the user to locate a file on their computer, consider buying an extension from the AssetStore, there’s one that allows to have a file open dialog at runtime.
Users could specify the url/path then the system loads the image like the following example
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public class NewBehaviourScript : MonoBehaviour
{
[SerializeField]
private Image background;
[SerializeField]
private string url;
// local: url = "file:///D:/Images/example.jpg";
// internet: url = "http://i.imgur.com/UVk2aZZ.png";
void Start ()
{
StartCoroutine(downloadImage(url));
}
private IEnumerator downloadImage(string urlImage)
{
WWW wwwRequest = new WWW(urlImage);
yield return wwwRequest;
if (wwwRequest.error != null)
{
Debug.Log("<color=red>Error: " + wwwRequest.error + "</color>");
yield break;
}
Texture2D image = wwwRequest.texture;
background.sprite = Sprite.Create(image, new Rect(0f, 0f, image.width, image.height), Vector2.zero);
}
}