- Home /
This question was
closed Sep 28, 2015 at 04:35 PM by
getyour411.
Terrain Painting Script
I want to change the terrain's splat color in order to change the texture(terrain type). This is for a terrain painter script. It should work more or less as seen below, taking in account more things. But the problem is I tried this small code to see if it works but it doesn't change the texture. I'm changing the red from the first splat (which is "plains") to green or blue ("mountains" and another). If it works the whole terrain should look like mountains on starting the game, but it doesn't. Any clue?
using UnityEngine;
using System.Collections;
public class TerrainPainter : MonoBehaviour {
public Terrain terrainToPaint;
private int splatResolution;
private Texture2D splat0;
// Use this for initialization
void Start () {
splat0 = terrainToPaint.terrainData.splatPrototypes[0].texture;
splatResolution = splat0.width;
for(int y=0;y<=splatResolution;y++){
for(int x=0;x<=splatResolution;x++){
splat0.SetPixel(x,y,Color.blue);
}
}
}
}
Thanks
Comment
I've been looking around a bit more. Saw stuff with get and set alphamaps but i don't really understand how to use it. Can anyone explain? I don't get the "float[0,0,0]" meaning