- Home /
Wireframe Rendering on Android
I've used GL.wireframe to set up wireframe rendering on PC however this function literally does nothing on my tablet. I assume the guys over at Unity haven't put this in yet which is fine but does anyone know how I would be able to achieve the same effect without it?
Thanks
EDIT :
Since I have found a method of achieving a wireframe. However this only works by attaching the script to objects of low complexity. I would prefer for a similar effect to be done on all objects in the scene simultaniously
using UnityEngine;
using System.Collections.Generic;
public class WireFrameCD : MonoBehaviour
{
Mesh LastMesh;
Material LastMaterial;
string lineshader = "Shader \"Unlit/Color\" { Properties { _Color(\"Color\", Color) = (0, 1, 1, 1) } SubShader { Lighting Off Color[_Color] Pass {} } }";
public void OnEnable()
{
var mesh = gameObject.GetComponent<MeshFilter>().sharedMesh;
var renderer = gameObject.GetComponent<MeshRenderer>();
LastMaterial = renderer.material;
LastMesh = mesh;
var vertices = mesh.vertices;
var triangles = mesh.triangles;
var lines = new Vector3[triangles.Length];
int[] indexBuffer;
var GeneratedMesh = new Mesh();
for (var t = 0; t < triangles.Length; t++)
{
lines[t] = (vertices[triangles[t]]);
}
GeneratedMesh.vertices = lines;
GeneratedMesh.name = "Generated Wireframe";
var LinesLength = lines.Length;
indexBuffer = new int[LinesLength];
var uvs = new Vector2[LinesLength];
var normals = new Vector3[LinesLength];
for (var m = 0; m < LinesLength; m++)
{
indexBuffer[m] = m;
uvs[m] = new Vector2(0.0f, 1.0f); // sets a fake UV (FAST)
normals[m] = new Vector3(1, 1, 1);// sets a fake normal
}
GeneratedMesh.uv = uvs;
GeneratedMesh.normals = normals;
GeneratedMesh.SetIndices(indexBuffer, MeshTopology.LineStrip, 0);
gameObject.GetComponent<MeshFilter>().mesh = GeneratedMesh;
Material tempmaterial = new Material(lineshader);
renderer.material = tempmaterial;
}
public void OnDisable()
{
gameObject.GetComponent<MeshFilter>().mesh = LastMesh;
gameObject.GetComponent<MeshRenderer>().material = LastMaterial;
}
}
Comment
You have to pay for this this isn't a solution... I take my thanks back X_X
You never said it had to be a free solution. Vectrocity is a tool that every other Unity developer depends on. Its certainly a solution, just not free.