Here is an example code for simply replacing the image to another one assigned in editor, but you can obviously get it some other way.
using UnityEngine;
using UnityEngine.UI;
public class SpriteReplace : MonoBehaviour
{
[SerializeField]
private Sprite sprite = null; // Assigned in editor
// Use this for initialization
void Start()
{
gameObject.GetComponent().sprite = sprite;
}
}
↧