How to animate disappearing Object?

I want a GameObject like the cube do fade in or fade out when I want it to.
With fading in and out I mean that the Object seems to disappear and slowly becomes invisible.

I know that if I want to make an Object invisible I can do gameObject.SetActive(false). But I want it to be animated.
I also tried changing the Renderers alph over time. That works but doesn´t look good. And even if the object is fully transparent you can still see it.

So I thought about creating a transparent wall that somehow hides the Object. So that you don´t see the wall and you don´t see the gameObject. I don´t know if this is even possible.

Does anyone have a better aproach about doing this? Or do you have any idea on how I would realize my idea?
Thanks in advance!

you need shaders for this.

Shader "Custom/Fade" {
	Properties
    {
        _Color ("Color", Color) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _Glossiness ("Smoothness", Range(0,1)) = 0.5
        _Metallic ("Metallic", Range(0,1)) = 0.0
        _Visibility ("Visibility", Range(0,1)) = 1
    }
    SubShader
    {
        Tags {"Queue" = "Transparent" "RenderType"="Transparent" }
        LOD 200
   
        CGPROGRAM
 
        #pragma surface surf Standard fullforwardshadows alpha:fade
        #pragma target 3.0
 
        sampler2D _MainTex;
        float _Visibility;
 
        struct Input {
            float2 uv_MainTex;
        };
 
        half _Glossiness;
        half _Metallic;
        fixed4 _Color;
 
        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
            o.Albedo = c.rgb;
            o.Metallic = _Metallic;
            o.Smoothness = _Glossiness;
            o.Alpha = _Visibility;
        }
        ENDCG
    }
    FallBack "Standard"
}

This is a basic Standard Surface Shader. I modified a bit so you can change the visibitily.
All you need to do is make a script that changes the _Visibility value.

bool FadeIn() {
	float val = Mathf.Lerp (0, 1, t);
	t += speed * Time.deltaTime;
	renderer.material.SetFloat ("_Visibility", val);
	return t > 1;
}

If the Fade is done the method returns true. After every fade you need to reset the variable t to 0.
Good Luck!

You need to create your own shader if ou want it to be perfect. Plugins like Amplify Shader and Shader Forge can help you create it.

If you have SpriteRenderer, you can create animation where you change alfa value of color from 1 to 0 over time.