coroutine and setactive

I want cube to disappear at first, and appear after 3s. I tried in two ways(using SetActive and using oppacity) but both didn’t work. Can you tell me what’s the problem?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class cube : MonoBehaviour
{
    public GameObject objectCube;
    private void Awake()
    {
        objectCube.SetActive(false);
    }
    IEnumerator AppearCube()
    {
        yield return new WaitForSeconds(3);
        objectCube.SetActive(true);
    }
    private void Start()
    {
        StartCoroutine(AppearCube());
    }
}

and

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class cube : MonoBehaviour
{
    public Color oppacity;
    public Renderer cubeRenderer;
    private void Awake()
    {
        oppacity = cubeRenderer.material.color;
        oppacity.a = 0;
    }
    IEnumerator appearing()
    {
        yield return new WaitForSeconds(3);
        oppacity.a = 1;
    }
    private void Start()
    {
        StartCoroutine("appearing");
    }
}

Hey there,

if you add a Debug.Log to your Start function you will know what’s going wrong in method 1.

An object which is Disabled ( SetActive(false) ) will not run the functions of their components. This includes Start and Update but also any Coroutines.

You can solve this if you just disable the MeshRenderer Component instead of the complete GameObject.