Fadeout GameObject C# 2D unity

So I load a scene for the player to start in. But, here I have a “Splashscreen” so to speak and I want it to fade away before the game really start. The way I am doing it now is just that I have created a new GameObject that I have added a UI image to and my text. For now I have just coded it like this(but this oviesly just deactivates the screen):

public class Splashscreen : MonoBehaviour

public GameObject SpScreen;


void Start()
{

}

// Update is called once per frame
void Update()
{
    if (Input.anyKeyDown)
    {
            SpScreen.SetActive(false);
            Time.timeScale = 1;
        }
    }
}

You’ll need an Image component on the game object for this to work. Gives you the basics, you can change as needed.

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class PauseScreen : MonoBehaviour 
{
	public float intensity;// = 0.0025f;
	public bool fadeIn, flashing;

	private Image image;
	private Color colour;
	private float r, g, b, a;
	private bool increaseAlpha;

	void Start () 
	{
		image = GetComponent<Image>();


		if(!flashing)
		{

			//If fading out.
			if(!fadeIn)
			{
				r = 1.0f;
				g = 1.0f;
				b = 1.0f;
				a = 1.0f;
			}

			//If fading in.
			if(fadeIn)
			{
				r = 0.0f;
				g = 0.0f;
				b = 0.0f;
				a = 0.0f;
			}

			increaseAlpha = false;

			colour = new Color(r,g,b,a);

			image.color = colour;

		}

	}

	void Update () 
	{
		if(GameManager.pause)
		{
			if(flashing)
			{
				CalculateFlash();
				colour = new Color(1.0f,1.0f,1.0f,a);
				image.color = colour;
			}
			else
			{
				fadeIn = true;
				FadeProcess();
			}
		}
		else
		{
			fadeIn = false;
			FadeProcess();
		}

	}

	private void FadeProcess()
	{
		//If fading out.
		if(!fadeIn)
		{
			if(a >= 0.0001f)
			{
				r -= intensity;
				g -= intensity;
				b -= intensity;
				a -= intensity;
			}
			else
			{

				//full = false;
			}
		}

		//If fading in.
		if(fadeIn)
		{
			if(a <= 0.9999f)
			{
				r += intensity;
				g += intensity;
				b += intensity;
				a += intensity;
			}
			else
			{

			}
		}

		colour = new Color(r,g,b,a);
		image.color = colour;
	}

	void CalculateFlash()
	{

		//First increase alpha value.
		if(increaseAlpha)
		{
			//Is it fully visible yet?
			if(a <= 0.9f)
			{
				//No, continue to increase alpha value.
				a += intensity;
			}
			else
			{
				//It's fully visible now.
				increaseAlpha = false;
			}

		}
		if(!increaseAlpha)
		{
			//Is it fully invisible yet?
			if(a >= 0.1f)
			{
				//No continue to decrease alpha value.
				a -= intensity;
			}
			else
			{
				//It's fully invisible now.
				increaseAlpha = true;
				//return;
			}
		}



	}
}

There are better ways going about this but this will be a good start for you.

Hope that helps