change spriterenderer sprite 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