# Trying to make my own plane using only 2 triangles?

So unity provides gameobject creation of a plane which contains a lot of triangles in which Unity calculates which is really unneeded for a simple plane. I was following a tutorial on how to do this, but I am getting an error.

Optimized Plane script:

``````#pragma strict

class OptPlane extends Editor{

static function Init (){
var customPlane : GameObject = new GameObject("Optimized Plane");
var meshFilter : MeshFilter  = customPlane.AddComponent(MeshFilter);

var destination : String = "Asset/Model/OptimizedPlane.asset";
var mesh : Mesh = AssetDatabase.LoadAssetAtPath(destination, Mesh);

if(! mesh){
mesh      = Mesh();
mesh.name = 'Optimized Plane';

var vertices : Vector3[]  = [Vector3(-1,0,1), Vector3(1,0,1), Vector3(1,0,-1), Vector3(-1,0,-1)];
var uv       : Vector2[]  = [Vector2(-1,1), Vector2(1,1), Vector2(1,-1), Vector2(-1,-1)];
var tangents : Vector4[]  = [Vector4(-1,0,1,1), Vector4(1,0,1,1), Vector4(1,0,-1,1), Vector4(-1,0,-1,1)];
var triangles: int[]      = [0,1,3,3,1,2];

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

mesh.RecalculateNormals();
mesh.RecalculateBounds();
mesh.Optimize();
AssetDatabase.CreateAsset(mesh, destination);
AssetDatabase.SaveAssets();
}

meshFilter.mesh = mesh;
Selection.activeObject = customPlane;
}

}
``````

Warning: UnityException: Creating asset at path Asset/Model/OptimizedPlane.asset failed.
OptPlane.Init () (at Assets/Editor/OptPlane.js:32)

I understand that it can’t create it to this location I sent it, but from the tutorial he did nothing special besides create a “Model” folder and it just worked for him. Also, what is this .asset extension, I am just guessing it is what Unity uses to create objects in the scene or something.

Try: Assets/Model/OptimizedPlane.asset