Sep
22
2015

Increase Terrain Detail Draw Distance in Editor

terrain_detail_draw_distance_250

Its quite annoying how the grass fades in editor (since 250 is the maximum view distance in Terrain settings),
but you can force the draw distance higher with simple script whichs runs in editor

References:
http://docs.unity3d.com/ScriptReference/Terrain-detailObjectDistance.html
http://docs.unity3d.com/ScriptReference/ExecuteInEditMode.html

Sample code: *Note this runs with Update loop so you can adjust the public variable “distance”, but usually just setting it once is enough..


using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class ForceGrassDistanceInEditor : MonoBehaviour {
public float distance=250; // 250 is max in terrain settings, but not here
Terrain terrain;
void Start () {
terrain = GetComponent<Terrain>();
if (terrain==null)
{
Debug.LogError("This gameobject is not terrain, disabling forced details distance", gameObject);
this.enabled=false;
return;
}
}
// WARNING: this runs update loop inside editor, you dont need this if you dont change the value
void Update()
{
terrain.detailObjectDistance = distance;
}
}


Leave a comment

Connect

Twitter View LinkedIn profile Youtube Github Join Discord Twitch Instagram BlueSky

UnityLauncherPro

Get UnityLauncherPRO and work faster with Unity Projects!
*free unity hub alternative

@unitycoder_com

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.