I have a wireframe shader on a object.
But what I need is to get access to each triangle in the wireframe. To get each triangle coordinates in the connected points and each triangle size and other stuff.
For example to color a specific triangle in the wireframe how can it be done ?
I’m using this shader/s: GitHub - Chaser324/unity-wireframe: General purpose wireframe shaders for use in Unity.
I know how to get the triangles vertices and normals and uv arrays from a mesh.
And how to change them and set new vertices or normals or uv.
But I want to change it on the wireframe. For example to color one specific triangle and the rest will still be wireframe. Or to get a specific triangle 3 connections positions and color one of the three lines of the triangle.
The problem I think is that I’m using this shader transparent and when I try to change the triangles color it will not effect it unless I change the shader back to standrad. But I want to use the wireframe transparent shader and color the wireframe triangles.
This is the script I’m using trying to color the wireframe triangles:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MeshGenerator : MonoBehaviour
{
private void Start()
{
Mesh mesh = GetComponent<MeshFilter>().mesh;
Vector3[] vertices = mesh.vertices;
// create new colors array where the colors will be created.
Color[] colors = new Color[vertices.Length];
for (int i = 0; i < vertices.Length; i++)
colors[i] = Color.Lerp(Color.red, Color.green, vertices[i].y);
// assign the array of colors to the Mesh.
mesh.colors = colors;
}
}
It’s not giving any errors but also not coloring anything on the wireframe.