In my OpenGL apps, one of my tricks that I've used often for displaying heads up displays and ui elements, is to have a sorted mesh of triangles and then only render a portion of them.
In one game I have a circular fuel gauge. I made a mesh of triangles using a triangle fan that spans around the circle. In code I can limit the number of triangles that it's drawing to make the fuel gauge appear at that % of fuel.
So in this example I take the % of fuel left, multiply by the number of segments in the fan, and then draw it:
glDrawElements(GL_TRIANGLE_FAN, (int)remainingFuel+1, GL_UNSIGNED_INT, (void *) (0 * sizeof(GLuint)));
If 50% of the fuel is left it draws 50% of the triangles in the fan which appears to be half the circle shape.
Can this easily be replicated in Unity3D? Where I can limit the range of triangles of a mesh that will render to a specific start and stop range?
Does Unity3D even do triangle fans?
Or do I need to figure out a new way to do this?
By the way I do know how to create procedural meshes in unity code (C#) but am still fairly new to Unity. I know I could store the entire mesh in one class and then copy only a portion of it to a game object based on the fuel level. I'd rather not create a new version of the mesh for each frame because the fuel is constantly changing. It seems more efficient to just limit the count on a non-changing mesh.