Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Turn off rendering of a terrain

Discussion in 'Editor & General Support' started by Horza, Dec 14, 2009.

  1. Horza

    Horza

    Joined:
    Nov 26, 2009
    Posts:
    20
    There are two terrains in my scene: one for rendering, the other for collision. Now there is question: how to make not to render the second terrain? I've tried "renderer.enabled = false;", but it doesn't work.

    sorry for my English
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,400
    The terrain doesn't have a renderer as such, so you must disable the terrain script instead.

    Code (csharp):
    1. GetComponent(Terrain).enabled = false;
    No need to apologize for your English, by the way. It would sound more typical if the second sentence was written like this: "Now the question is: how to make the second terrain not render?" The rest is perfect.

    --Eric
     
  3. Horza

    Horza

    Joined:
    Nov 26, 2009
    Posts:
    20
    @Eric5h5: quite simple solution, thanks.
     
  4. Jagwire

    Jagwire

    Joined:
    Dec 5, 2013
    Posts:
    59
    How does the Terrain render itself then?
     
  5. VitruvianStickFigure

    VitruvianStickFigure

    Joined:
    Jun 28, 2017
    Posts:
    38
    I know this question was roughly a decade ago, but it's still basically the first Google result and I feel I have relevant basic information on hiding a terrain. (This is with version 2021.3.)

    The easiest way to keep it from rendering, without using a script, is to select the terrain itself in the scene view, go into Terrain Settings in the inspector, and turn off the "Draw" option.
    Terrain Draw Option.png

    This will prevent it from rendering. It's not the only way, though, depending on what you're trying to do... You can also add your terrain to a new rendering layer and simply turn that layer off on your main camera. Things like colliders will still work. (This might also be useful for controlling post-processing effects with other cameras.)

    Then you don't have to mess around with renderer settings at all.