Hi all,
I'm making a map, and I wanted to increase the terrain draw distance, but it can only go to 2000.
So I used a script :
using UnityEngine;
[ExecuteInEditMode]
public class BasemapDistanceSet : MonoBehaviour
{
public float BasemapDistance = 20000;
private Terrain terrain;
void OnEnable ()
{
terrain = GetComponent<Terrain> ();
#if UNITY_EDITOR
UnityEditor.EditorApplication.update += Set;
#endif
}
void OnDisable()
{
UnityEditor.EditorApplication.update -= Set;
}
#if !UNITY_EDITOR
void Update ()
{
Set
}
#endif
void Set ()
{
if (terrain == null)
terrain = GetComponent<Terrain> ();
else if (terrain.basemapDistance != BasemapDistance)
terrain.basemapDistance = BasemapDistance;
}
}
In Unity scene it works, but when it try to save mod, it says that there are compiler errors. Does anyone have the solution?
Fixed!
@MisterT thank you very much 😉😉😉
@mikoyanster I think it's just because you have to write it step by step, and select the directoriy inside the console. I made a tutorial at the end of this post.
@MisterT Hi again, i´m trying use in the console, but gave me this message... "Command terrain not found" can you help me?
@mikoyanster Idk, it would be great !
@MisterT it´s great!!! but would there be any way for the change to be automatic when loading the map?
Problem solved ! Just open the console in game, and type :
Now it looks beautiful !
@Gestour
@mikoyanster
@MOPCKOEDNISHE
@DuckMint
@Tully2001
This problem i had got un several experiments but i dont find a valid solution :-(
@Gestour
@mikoyanster
@MOPCKOEDNISHE
@DuckMint
@Tully2001
@WNP78 I tried to add (), no errors in the console, but still doesn't want to save the mod.
@WNP78 @MOPCKOEDNISHE Thanks for your answers, I'm making a big map based on geographical data. I imported heightmap, and there is only one big photo texture (8000*8000). I just wanted to make it less blurry when I move away from the ground. The problem is I am a beginner on unity.
If i correct understand you, you want enable or disable terrain in dependence by distance? It is unusual way. But i think that the draw distance depend from Rendering range of camera. If you want to disable game camera and use your own camera, then write script:
Firstly, if it doesn't let you set above that level in the inspector, it probably won't let you via a script. Secondly, you're using what's called preprocessor directives. These are the lines that start with
#
. The#if
command used (#if !UNITY_EDITOR
basically means "anything inside this block should only be included if UNITY_EDITOR is not defined (the!
means "not" or "inverse"), which therefore means it will only be included when building for the game and not the editor). So the code in update doesn't get run (or even compiled) in the editor, which is why you don't get an error in the editor. However when it is compiled for leaving the editor, there is an error because you missed the empty brackets afterSet
(you always need brackets to execute a method, even if there are no parameters). It does seem like a strange and overcomplicated way of implementing it though, I'm not sure why it needs to be different in the editor and the game.Wow it would be great if the draw distance was twice as far in the regular game.
@Gestour
@mikoyanster
@MOPCKOEDNISHE
@DuckMint
@Tully2001