Trouble creating reference of image in script.

I’m trying to do this:

 private Image image;

 //On Start I wrote:
 image = new Image();

Well, it doesn’t work. I get a “NullReferenceExeption” (if there’s any annoying situation, then the null reference is on top of the list).

Unity also says I can’t use it because of the level of protection of Image.Image(). I’ve got a look at it, and it’s literaly protected.

Any ideas on how to solve this? Thanks in advance.

You can’t since it’s a monobehaviour, you must use AddComponent

AddComponent<Image>();

To set new sprite:

GetComponent<Image>().sprite = newSpriteImage;