Make a Gameobject invisible in Unity

Gameobjects are the core elements of any Unity game. You can add or remove component from gameobjects to change its behavior. You can make it move in any way you like by adding a script or you can make it invisible by changing the renderer properties. In this tutorial, we will see how to make a Gameobject invisible using Unity editor or using code.

How a Gameobject is rendered in Unity

Any Gameobject is visible in the game only if some type of renderer is added to it. Unity uses this renderer class to calculate the 3-dimensional data to display the Gameobject. That might be little hard to understand. Let’s take an example to understand that.

Say you have a 3D sphere on your scene. Basically the end display is a 2D image with 3D effect. The renderer takes the 3D data of the Gameobjects and creates a 2D image. The images are shown in such a way that the human eyes perceive it as 3D.

Making a Gameobject Invisible in Unity

Now that you know how a Gameobject gets displayed in Unity, you might have guessed how to make it invisible. Yes, you just need to disable the renderer. Without a renderer the Gameobject is not taken into account for display. Unity keeps the other component active even if the renderer is disable. You can still move the Gameobject and make it respond to physics.

How to disable the renderer?

  1. Select the Gameobject in the hierarchy window.
  2. Go to the inspector window and look for renderer.
  3. The type of renderer will depend on the type of Gameobject.
  4. Uncheck the renderer to make the Gameobject invisible.
Disable renderer

Disable the renderer using code

You need to get the renderer component using the Getcomponent function and then set the renderer to false.

Here is a code snippet to make the Gameobject invisible on scene start. You need to attach this to the object that you want to make invisible.

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

public class Invisible : MonoBehaviour
    Renderer test;
    // Start is called before the first frame update
    void Start()
        test= GetComponent<MeshRenderer>();
        test.enabled= false;


You can simply set the renderer to true to make the Gameobject visible again. If you are looking to create a transparent Gameobject then you need to create a new material and set the Rendering mode to transparent.

With this you can make your Gameobject visible and invisible at any time. If you have any questions, feel free to leave a comment below.

Unity course banner

2 thoughts on “Make a Gameobject invisible in Unity”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.