You can make terrain invisible in Unity by disabling the Terrain component or using a no-draw material.
Here's a breakdown of the methods:
1. Disabling the Terrain Component
This is the simplest method. Disabling the Terrain component prevents it from rendering.
-
In the Inspector: Select the Terrain object in your scene. In the Inspector window, uncheck the box next to the "Terrain" component's name to disable it.
-
Using Scripting: Use the following C# code to disable the Terrain component:
GetComponent<Terrain>().enabled = false;
To re-enable the terrain, use:
GetComponent<Terrain>().enabled = true;
2. Using a No-Draw Material
If you need the Terrain component to remain enabled but want to hide it, you can assign it a "no-draw" material. This material is designed to cull both the front and back faces, effectively making the object invisible.
-
Creating a No-Draw Material (Shader Graph Example):
While a built-in shader isn't available for this exact purpose, you can create one using Shader Graph (if using a Scriptable Render Pipeline). In Shader Graph, the key is to set "Two Sided" to "Off" or create a material that doesn't render any output.
-
Assigning the Material: Select the Terrain object. In the Inspector, locate the "Terrain" component. Find the "Settings" section within the component. Assign your no-draw material to the "Material" slot.
Example Scenario and Choice Considerations
- Simple Hide/Show: If you simply want to toggle the terrain's visibility, disabling the component is usually sufficient.
- Complex Rendering Logic: If you need the Terrain component to still exist (e.g., for collision detection or other scripts) but want to prevent it from rendering under specific circumstances, a no-draw material might be more appropriate.