- Home /
How to set Terrain Texture via Script?
I have search high and low, both across this UnityAnswers site and the Internet. However creative my searches are, I cannot find a single answer to the simple question: How do I set terrain textures like the inspector using a script?
Let me make this very clear. When your terrain object is selected, from the inspector properties you can click on the paint texture button which opens up your options for painting textures including the edit textures button. Clicking the edit textures button opens up a pop-up window that allows you to set up your SplatPrototype with the options to select your texture, a normal map, and the x, y size and offsets. Upon setting these you are immediately rewarded by seeing your (first) selected texture decorating your terrain.
I have already created a script that allows me to procedurally create my terrain at run-time. Now I want to be able to procedurally paint my terrain in a manner similar to the way setting the properties in the inspector works but through scripts. How do I do this?
As a side question, from what I can gather, it would appear to me that working with terrain objects is one of the poorest documented (and poorest understood) subjects, and yet I see people asking the same questions over and over. Why is this? And why is it that when people create basic terrain tutorials, they always leave out working with one of the most important components, the textures? Almost every tutorial I have found to date that involves working with textures uses the inspector only. Why is that? Does no one know how to script things like terrain texture in Unity? This is very frustrating.
Your answer
Follow this Question
Related Questions
Make a simple tree 1 Answer
Using a Gameobject for terrain. 1 Answer
How To produce cracks on terrain and buildings with earthquake ? 0 Answers
accidentally renamed folder, work gone? 2 Answers
Bugs with Terrian. Unity 5.4.0f3 FIXED 0 Answers