unity load sprite into spriterenderer code example
Example 1: change sprite of gameobject unity
gameObjectName.GetComponent<SpriteRenderer>().sprite = spriteName;
Example 2: sprite unity script
Resources.Load <Sprite>
gameObjectName.GetComponent<SpriteRenderer>().sprite = spriteName;
Resources.Load <Sprite>