create a sprite through script unity code example
Example 1: sprite unity script
Resources.Load <Sprite>
Example 2: unity set sprite image from script
Sprite myFruit = Resources.Load("fruits_1", typeof(Sprite)) as Sprite;
Resources.Load <Sprite>
Sprite myFruit = Resources.Load("fruits_1", typeof(Sprite)) as Sprite;