- Home /
GameObject coloring
Hey guys! I'm trying to color the gameobject's area based on what was clicked with the mouse(mouse's Position). the problem is that when I attach this script to my Cube gameobject it doesn't do anything. Do I need to use a shader for it? I'm using Diffuse one.. I also try VertexLit,etc.. but it doesn't solve the problem.
using UnityEngine; using System.Collections;
class TriangleHighlighter : MonoBehaviour{ // Use this for initialization void Start () { MeshFilter meshFilter = gameObject.GetComponent<MeshFilter>(); Mesh mesh = meshFilter.sharedMesh; Color[] vertexColors = mesh.colors; for(int i = 0; i < vertexColors.Length; ++i) { vertexColors[i] = Color.blue; } mesh.colors = vertexColors; // update the vertex colors }
// Update is called once per frame
void Update () {
}
}
Answer by Mike 3 · Jul 11, 2010 at 10:29 AM
You'll need to use a vertex coloured shader, like this one:
http://www.unifycommunity.com/wiki/index.php?title=VertexColor
Thanks $$anonymous$$ike! I've one more issue - which is coloring areas with the mouse. I believe I'll post the question today later on, math now, kkthxbye :)
Your answer
Follow this Question
Related Questions
Change vertex color of a mesh. 2 Answers
Color depending on vertex normal 1 Answer
Need help with using world position in shader 1 Answer
Strange artifacts on Vertex Color Shader 0 Answers
Shader to change Vertex Colors 0 Answers