Thursday, August 8, 2013

Modify Terrain Data in Unity3D during Runtime

How do you change the Pixel Error, Base Map Distance, Cast Shadows, Tree Distance and other settings from runtime, not in inspector using UnityScript or C#?

It's relatively easy when you reference the Component on Terrain. This script should work:

Terrain.activeTerrain.GetComponent.<Terrain>().heightmapPixelError = 200;
for(var gameObj : Terrain in GameObject.FindObjectsOfType(Terrain)) {
        gameObj.GetComponent.<Terrain>().heightmapPixelError = 200;
        gameObj.GetComponent.<Terrain>().basemapDistance = 200;
        gameObj.GetComponent.<Terrain>().castShadows = false;
        gameObj.GetComponent.<Terrain>().treeDistance = 500;
        gameObj.GetComponent.<Terrain>().detailObjectDistance = 25;

      }

1 comment:

  1. Get Free Softwares from my blog, Softwares Heaven

    ReplyDelete

Generating "Always On Top" NSWindow in macOS across all detected displays

Also: Using UIKit & Cocoa Frameworks using Objective-C In m acOS or OS X , written in either Objective-C or Swift  Langues, you m...