Create 2d mesh filter

Hi, I’m trying to make a 2d game for my university project.But i can’t create 2 triangles mesh.When I used this code, it’s work but only game when starting.I stop game and my object be invisible.How do i create useable 2d mesh filter like cube,plane etc.
Thanks.
125*Sory for my bad english :)*125

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(MeshRenderer)), RequireComponent(typeof(MeshFilter))]
public class CreatePlaneMeshExample : MonoBehaviour
{
void Start()
{
GetComponent().mesh = CreatePlaneMesh();
}

Mesh CreatePlaneMesh()
{
    Mesh mesh = new Mesh();

    Vector3[] vertices = new Vector3[]
    {
        new Vector3( 1, 0,  1),
        new Vector3( 1, 0, -1),
        new Vector3(-1, 0,  1),
        new Vector3(-1, 0, -1),
    };

    Vector2[] uv = new Vector2[]
    {
        new Vector2(1, 1),
        new Vector2(1, 0),
        new Vector2(0, 1),
        new Vector2(0, 0),
    };

    int[] triangles = new int[]
    {
        0, 1, 2,
        2, 1, 3,
    };

    mesh.vertices = vertices;
    mesh.uv = uv;
    mesh.triangles = triangles;

    return mesh;
}

}

Your mesh is creating in start() method, that calls only when you run application. Mesh is just not exist before. So, you can try to use attribute ExecuteInEditMode or you can save a created mesh to a file and set it to a mesh filter. You can save a mesh to a file by using ObjExporter.

I try but i didn’t :frowning: Can you create example and send me ? hyper007[at]windowslive[dot]com