c# set sprite to a sprite from file code example
Example 1: change sprite of gameobject unity
gameObjectName.GetComponent().sprite = spriteName;
Example 2: sprite unity script
Resources.Load
gameObjectName.GetComponent().sprite = spriteName;
Resources.Load