- Home /
How do I alter a plane to match the navMesh without altering the texture?
I creating a plane as the layer in which I can teleport to when using the SteamVR's interaction system. I created a Plane Object and attached the Teleport Area script to the plane. At this point the teleportation area shows a texture with a big square broken up into four little squares. This is because the plane is just a regular square. Now with the complete square, I could potentially teleport to an area under another object. I baked a navMesh and used the triangles from that and applied that to the plane with this code on Awake:
NavMeshTriangulation triangles = NavMesh.CalculateTriangulation();
mesh = GetComponent<MeshFilter>();
mesh.mesh.vertices = triangles.vertices;
mesh.mesh.triangles = triangles.indices;
Which this worked fine for creating the teleportable area, but the problem that I am having now is the texture. I would like to have the texture applied as the same way as it was with the square but not the missing "holes" in the square will not show that part of the texture. Here is an image of what I have in mind (It was drawn in paint real fast not done with precision): The Normal Plane is how the plane looks before the transformation. The middle green block represents what the nav mesh looks like after it is baked. The third final picture is how I want the texture to look. I have it so the plane is in that shape but the texture is just a solid color (The color of the lines). I've tried changing the texture's wrap mode property to clamp and that didn't do it. I also tried to use mesh.mesh.uv = new Vector2[] = {Vector2.zero, Vector2.one};
and that didn't work either.
Does anyone have a solution to this? Also I would like to make it so that if the nav mesh changes, I don't have to change the code or anything.