GL Lines work on one platform, others, not so much

I am currently in the process to putting out a couple of builds of a project I am actively working on Independently. I will be deploying out to Linux, Windows and Mac. When I build out the game and send it to any Mac computers, no problems whatsoever. However, if all of my Windows and Linux players are experiencing the same problems. Here’s whats going on.

I am using GL lines to turn things from a 3D mesh into a “wireframe” texture through javascript. Here is that code:

var lineColor : Color;
var backgroundColor : Color;
var ZWrite = true;
var AWrite = true;
var blend = true;

private var lines : Vector3[];
private var linesArray : Array;
private var lineMaterial : Material;
private var meshRenderer : MeshRenderer;


public function Start ()
{
    meshRenderer = GetComponent(MeshRenderer);
    if(!meshRenderer) meshRenderer = gameObject.AddComponent(MeshRenderer);
    meshRenderer.material = new Material("Shader \"Lines/Background\" { Properties { _Color (\"Main Color\", Color) = (1,1,1,1) } SubShader { Pass {" + (ZWrite ? " ZWrite on " : " ZWrite off ") + (blend ? " Blend SrcAlpha OneMinusSrcAlpha" : " ") + (AWrite ? " Colormask RGBA " : " ") + "Lighting Off Offset 1, 1 Color[_Color] }}}");
    lineMaterial = new Material("Shader \"Lines/Colored Blended\" { SubShader { Pass { Blend SrcAlpha OneMinusSrcAlpha ZWrite Off Cull Front Fog { Mode Off } } } }");
    lineMaterial.hideFlags = HideFlags.HideAndDontSave;
    lineMaterial.shader.hideFlags = HideFlags.HideAndDontSave;

    linesArray = new Array();
    var filter : MeshFilter = GetComponent(MeshFilter);
    var mesh = filter.mesh;
    var vertices = mesh.vertices;
    var triangles = mesh.triangles;

    for (i = 0; i < triangles.length / 3; i++)
    {
        linesArray.Add(vertices[triangles[i * 3]]);
        linesArray.Add(vertices[triangles[i * 3 + 1]]);
        linesArray.Add(vertices[triangles[i * 3 + 2]]);
    }
    lines = linesArray.ToBuiltin(Vector3);
}

public function OnRenderObject()

{   
    meshRenderer.material.color = backgroundColor;
    lineMaterial.SetPass(0);
    GL.PushMatrix();
    GL.MultMatrix(transform.localToWorldMatrix);
    GL.Begin(GL.LINES);
    GL.Color(lineColor);

    for (i = 0; i < lines.length / 3; i++)
    {
        GL.Vertex(lines[i * 3]);
        GL.Vertex(lines[i * 3 + 1]);
        GL.Vertex(lines[i * 3 + 1]);
        GL.Vertex(lines[i * 3 + 2]);

        GL.Vertex(lines[i * 3 + 2]);
        GL.Vertex(lines[i * 3]);
    }

    GL.End();
    GL.PopMatrix();

}

When used on a Windows or Linux machine none of the lines rendered appear the color they are supposed to be. I know they are being drawn but the color is black not the color in the inspector (green, white, etc.) Any idea where to even begin?

EDIT: I looked a little further and testedout my builds and it looks like the mesh.renderer.material works, its just the lines that aren’t being put into the colors specified. This led me to start looking at OnRenderObject() to make sure that was working up to snuff. Thoughts?

I found that creating a new material via code shows up in the player, but not in the windows build. I used a material from the editor instead, and then it worked in the build :slight_smile: