when i change image to sprite the image changes unity code example
Example 1: change sprite of gameobject unity
gameObjectName.GetComponent<SpriteRenderer>().sprite = spriteName;
Example 2: load an image sprite script unity
void Start()
{
spriteArray = Resources.LoadAll<Sprite>("BirdHeroSprite");
}