GameObject to Terrain Object

Is there a way to convert a gameObject into a terrain object so i can access the terraindata?

The lengthy question :

So I have a script that places terrain tiles as the player moves about the terrain edges. I achieve this by calling Terrain.CreateTerrainGameObject() and positioning them. Is there a way to convert the returned GameObject back into Terrain because I need to do two things with them :

  1. SetNeighbors, so the LOD would match, and
  2. Stitch the terrain pieces.

2 Answers

2

You don’t need to convert anything; a Terrain is a GameObject, or specifically a component on a GameObject. Just access the Terrain component of the returned GameObject.

Wow, Thanks Eric! Didn't realize that Terrain could be accessed as a component. For reference, this is what I did : gameObject.GetComponent<Terrain>().terrainData; Thanks again!

A sensible solution is https://unity3d.com/learn/tutorials/topics/cloud-build/creating-your-first-source-control-repository ...

Aver, yo flipo, a lo que se refiere en realidad es convertir el GameObject en Terrain y pintar sobre el, no se refiere a crear un Terrain que es justamente lo que estaba buscando yo tambien