- Home /
Terrain Type Detection; Based On Splat Color
Hi, I'm trying to detect the color of each splat map to assign it a name, so it can be displayed on a tooltip, or used to change speed of objects based on their XZ position.
My idea is to input into a script, attached to a gameobject, all the splat maps used (3 in may case for now) and be able to, in the editor, assign a name to that texture. Then take that string and put it in the gui(that's not the hard part).
So here what I have for now, I've tried some things but I don't get what I want, this is just the input of splats and "plain" is supposed to be the red of the splat0. cntPos is the object's position. "_plain = splat0.GetPixel.red;" is what I want but it's not written like this. I don't know if it even makes sense xD
using UnityEngine;
using System.Collections;
public class TerrainTypeDetection : MonoBehaviour {
public Texture2D splat0;
public Texture2D splat1;
public Texture2D splat2;
private Vector3 cntPos;
private Color _plain;
// Use this for initialization
void Start () {
_plain = splat0.GetPixel.red;
}
// Update is called once per frame
void Update () {
}
}
I guess I have to use the "getpixel" somewhere and give it the object's transform position in XZ, but I don't know how to go from there to detect the color and extract it.
Any help on how should I use the functions and variables? Making this would help me make more complex thing based on terrain. And I'm creating a strategy game, so it's kind of important :) Thanks in advance
Your answer
Follow this Question
Related Questions
Modifying Terrain Splat Texture at Runtime 2 Answers
Tree terrain splatmap? 0 Answers
How to limit walkable map? 3 Answers
Material: What is a "Mask map" and when to use it? 0 Answers
I Can't see the hole terrain... Why? 1 Answer