-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriangle.cs
More file actions
48 lines (39 loc) · 945 Bytes
/
Triangle.cs
File metadata and controls
48 lines (39 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using UnityEngine;
using System.Collections;
public class Triangle : MonoBehaviour
{
Vector3[] vertices = new Vector3[] {
new Vector3 (-10, 0, 0),
new Vector3 (0, 20, 0),
new Vector3 (10, 0, 0)
};
int[] triangles = new int[] {
0, 1, 2
};
Vector3[] normals = new Vector3[] {
Vector3.forward,
Vector3.forward,
Vector3.forward
};
private MeshFilter mf;
void Start ()
{
mf = GetComponent<MeshFilter> ();
mf.mesh = new Mesh ();
mf.mesh.vertices = vertices;
mf.mesh.triangles = triangles;
mf.mesh.normals = normals;
GetComponent<MeshRenderer> ().material.color = Color.white;
}
void Update ()
{
// if (Input.GetKeyDown (KeyCode.A)) {
mf.mesh.vertices = new[] {
new Vector3 (Random.Range (1, 3), Random.Range (1, 3), 0),
new Vector3 (Random.Range (1, 3), Random.Range (1, 3), 0),
new Vector3 (Random.Range (1, 3), Random.Range (1, 3), 0)
};
// Debug.Log ("Up is pressed.");
// }
}
}