Help with custom Plane

this is driving me crazy. I have a custom plane component which redefines the vertices to just two triangles, and seems to work fine as follows:

	void Start ()
	{
		newVertices = new Vector3[4];
		newVertices[0] = new Vector3(5,0,5);
		newVertices[1] = new Vector3(-5,0,-5 );
		newVertices[2] = new Vector3(-5,0,5);
		newVertices[3] = new Vector3(5,0,-5 );
		
		newUV = new Vector2[4];
		newUV[0] = new Vector2(1,1);
		newUV[1] = new Vector2(0,0);
		newUV[2] = new Vector2(0,1);
		newUV[3] = new Vector2(1,0);
		
		newTriangles = new int[6];
		newTriangles[0] = 0;
		newTriangles[1] = 1;
		newTriangles[2] = 2;
		newTriangles[3] = 0;
		newTriangles[4] = 3;
		newTriangles[5] = 1;
		
    	_mesh = GetComponent<MeshFilter>().mesh;
		_mesh.Clear();
    	_mesh.vertices = newVertices;
    	_mesh.uv = newUV;
	    _mesh.triangles = newTriangles;
		_mesh.RecalculateNormals();
	}

However, like a plane this is positioned laying flat and face up. Therefore, I need to rotate the plane to correctly orient it the way I need it.

I’m trying what I thought would be a simple change to create the plane facing toward the z-1 instead of y+1. That way I could more easily use it for billboards too. Otherwise, I need to perform a LookAt, then rotate it by 90 degrees along the right axis, but I find that sometimes the required rotation changes which might be a bug, but I’m thinking it has to do with the math?

Anyway I made the slightest of change to the vertices as follows :

	void Start ()
	{
		newVertices = new Vector3[4];
		newVertices[0] = new Vector3(5,5,0);
		newVertices[1] = new Vector3(-5,-5,0 );
		newVertices[2] = new Vector3(-5,5,0);
		newVertices[3] = new Vector3(5,-5,0 );
		
		newUV = new Vector2[4];
		newUV[0] = new Vector2(1,1);
		newUV[1] = new Vector2(0,0);
		newUV[2] = new Vector2(0,1);
		newUV[3] = new Vector2(1,0);
		
		newTriangles = new int[6];
		newTriangles[0] = 0;
		newTriangles[1] = 1;
		newTriangles[2] = 2;
		newTriangles[3] = 0;
		newTriangles[4] = 3;
		newTriangles[5] = 1;
		
    	_mesh = GetComponent<MeshFilter>().mesh;
		_mesh.Clear();
    	_mesh.vertices = newVertices;
    	_mesh.uv = newUV;
	    _mesh.triangles = newTriangles;
		_mesh.RecalculateNormals();
	}

In both examples the triangles are created in a clockwise direction which I think is right, but I’ve tried both just in case. Regardless I can’t get the second example to work at all, when it’s basically identical to the first but I’m using Y instead of Z. It’s gotta be something stupid I’m doing, but I don’t see it. Any help is greatly appreciated.

Thanks

It’s fine. Maybe you’re looking at it from the wrong side.

–Eric

I thought that, but I went in with the debugger and rotated it every which way and its not working. I wonder if its something with the shader used for the built in plane that specifically uses the X and Z and not the Y? Otherwise, it just doesn’t make any sense for me.

It is working though; I tried it and like I said it’s fine. The built-in plane uses whatever shader you assign to it; by default it’s the Diffuse shader, which has nothing to do with x/y/z axes.

–Eric