146 lines
3.5 KiB
C#
146 lines
3.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[ExecuteInEditMode]
|
|
public class MeshScript : MonoBehaviour
|
|
{
|
|
|
|
//private Color[] colors = new Color[15];
|
|
private Vector3[] vertices = new Vector3[15];
|
|
private Vector2[] uv = new Vector2[15];
|
|
private int[] triangles = new int[39];
|
|
|
|
void Start() {
|
|
|
|
// top
|
|
vertices[0] = new Vector3(1.5f, 6);
|
|
vertices[1] = new Vector3(1, 5);
|
|
vertices[2] = new Vector3(2, 5);
|
|
vertices[3] = new Vector3(1, 4);
|
|
vertices[4] = new Vector3(2, 4);
|
|
vertices[5] = new Vector3(1, 3);
|
|
vertices[6] = new Vector3(2, 3);
|
|
vertices[7] = new Vector3(1, 2);
|
|
vertices[8] = new Vector3(2, 2);
|
|
vertices[9] = new Vector3(1, 1);
|
|
vertices[10] = new Vector3(2, 1);
|
|
vertices[11] = new Vector3(3, 1);
|
|
|
|
// bottom right point
|
|
vertices[12] = new Vector3(3, 0);
|
|
vertices[13] = new Vector3(0, 1);
|
|
|
|
// bottom left point
|
|
vertices[14] = new Vector3(0, 0);
|
|
|
|
|
|
/* colors[0] = Color.red;
|
|
colors[1] = Color.green;
|
|
colors[2] = Color.blue;
|
|
colors[3] = Color.red;
|
|
colors[4] = Color.green;
|
|
colors[5] = Color.blue;
|
|
colors[6] = Color.red;
|
|
colors[7] = Color.blue;
|
|
colors[8] = Color.green;
|
|
colors[9] = Color.red;
|
|
colors[10] = Color.blue;
|
|
colors[11] = Color.green;
|
|
colors[12] = Color.blue;
|
|
colors[13] = Color.blue;
|
|
colors[14] = Color.blue;
|
|
|
|
colors[0].a = alpha; */
|
|
|
|
|
|
|
|
// Right wing points
|
|
/* vertices[10] = new Vector3(0,0);
|
|
vertices[11] = new Vector3(1,1);
|
|
vertices[12] = new Vector3(0,1);
|
|
|
|
|
|
|
|
|
|
uv[10] = new Vector2(0,1);
|
|
uv[11] = new Vector2(1,1);
|
|
uv[12] = new Vector2(0,0);*/
|
|
|
|
// top
|
|
triangles[0] = 1;
|
|
triangles[1] = 2;
|
|
triangles[2] = 0;
|
|
|
|
triangles[3] = 1;
|
|
triangles[4] = 4;
|
|
triangles[5] = 2;
|
|
|
|
triangles[6] = 1;
|
|
triangles[7] = 3;
|
|
triangles[8] = 4;
|
|
|
|
triangles[9] = 3;
|
|
triangles[10] = 5;
|
|
triangles[11] = 4;
|
|
|
|
triangles[12] = 5;
|
|
triangles[13] = 6;
|
|
triangles[14] = 4;
|
|
|
|
triangles[15] = 5;
|
|
triangles[16] = 8;
|
|
triangles[17] = 6;
|
|
|
|
triangles[18] = 5;
|
|
triangles[19] = 7;
|
|
triangles[20] = 8;
|
|
|
|
triangles[21] = 7;
|
|
triangles[22] = 9;
|
|
triangles[23] = 8;
|
|
|
|
triangles[24] = 9;
|
|
triangles[25] = 10;
|
|
triangles[26] = 8;
|
|
|
|
triangles[27] = 13;
|
|
triangles[28] = 9;
|
|
triangles[29] = 7;
|
|
|
|
triangles[30] = 13;
|
|
triangles[31] = 14;
|
|
triangles[32] = 9;
|
|
|
|
triangles[33] = 8;
|
|
triangles[34] = 10;
|
|
triangles[35] = 11;
|
|
|
|
triangles[36] = 10;
|
|
triangles[37] = 12;
|
|
triangles[38] = 11;
|
|
|
|
Mesh mesh = new Mesh();
|
|
|
|
mesh.vertices = vertices;
|
|
mesh.uv = uv;
|
|
mesh.triangles = triangles;
|
|
//mesh.colors = colors;
|
|
|
|
GameObject go = new GameObject("Mesh", typeof(MeshFilter), typeof(MeshRenderer));
|
|
go.transform.localScale = new Vector3(1, 1, 1);
|
|
|
|
go.GetComponent<MeshFilter>().mesh = mesh;
|
|
|
|
go.GetComponent<MeshRenderer>().material = new Material(Shader.Find("Live/PlainColor"));
|
|
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|