GameObject.renderer 已弃用

GameObject.renderer deprecated

我尝试了这个代码但是 Player.renderer.enabled = false; 不存在。 这是我的代码:

public IEnumerator RespawnPlayerCo()
{
    Instantiate(deathParticle, player.transform.position, player.transform.rotation);
    player.enabled = false;
    player.renderer.enabled = false; //error is here
    Debug.Log("Player Respawn");
    yield return new WaitForSeconds(respawnDelay);
    player.transform.position = currentCheckPoint.transform.position;
    Instantiate(respawnParticle, currentCheckPoint.transform.position, currentCheckPoint.transform.rotation);
}

根据 documentation:

Removed in version 5.3.5p6

Property renderer has been deprecated. Use GetComponent<Renderer>() instead. (UnityUpgradable)