Generating a triangle from 3 points

I try to generate a one colored triangle from 3 points, but I’m stuck…

So I want to make an empty game object with a script (preferably C#), that does this. The script uses 3 3d coordinates and a color (lets say blue) to generate it.

Can anyone help?

If you want to play in the OpenGL style, use the GL class to draw the triangle - there’s a very useful example in this topic.

But if you want to create a game object with a simple triangular mesh, take a look at the mesh topic in the Unity manual, or at the Mesh class in the docs - both have useful examples, and the later allows selection of C# language.

From the official docs on meshes

// Builds a mesh containing a single triangle with uv's.
function Start () {
    gameObject.AddComponent("MeshFilter");
    gameObject.AddComponent("MeshRenderer");
    var mesh : Mesh = GetComponent(MeshFilter).mesh;
    mesh.Clear();
    mesh.vertices = [Vector3(0,0,0), Vector3(0,1,0), Vector3(1, 1, 0)];
    mesh.uv = [Vector2 (0, 0), Vector2 (0, 1), Vector2 (1, 1)];
    mesh.triangles = [0, 1, 2];
}

…and then the official docs on materials has an example for setting material color

Here you can learn step by step how to draw a triangle just by code (Turn on English subtitles) Generacion procedural Unity: Triángulo C# - YouTube

Make a triangle I’m blender then export to unity and turn off the mesh renderer. Simply solution

Well, I not so recommended way, but a way you can generate a triangle is using calls to OpenGL directly:

GL.Begin( GL.TRIANGLES);
GL.Color( Color(1,1,1,1) );
GL.Vertex3( 0, 0, 1 );
GL.Vertex3( 1, 0, 1 );
GL.Vertex3( 0, 1, 1 );
GL.End();

Something to that effect, do some googling and you will find plenty of resources on OpenGL.

But, to make a GameObject that will rotate, scale and do everything you want, and have a triangle shape, you would be best off making the object in something like Blender.