forked from Unity-Technologies/Graphics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMeshSampling_ModifyMesh.cs
More file actions
42 lines (38 loc) · 1.05 KB
/
MeshSampling_ModifyMesh.cs
File metadata and controls
42 lines (38 loc) · 1.05 KB
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MeshSampling_ModifyMesh : MonoBehaviour
{
public Mesh mesh;
private float time = 0.0f;
private bool modified = false;
void Start()
{
time = 0.0f;
modified = false;
}
void Update()
{
time += Time.deltaTime;
if (!modified && time > 2.0f)
{
if (mesh)
{
var reference = new Vector3[]
{
new Vector3(-1.0f, 1.0f, 0.0f),
new Vector3(1.0f, 1.0f, 0.0f),
new Vector3(1.0f, -1.0f, 0.0f),
new Vector3(-1.0f, -1.0f, 0.0f),
};
var newVertices = new Vector3[mesh.vertexCount];
for (int i = 0; i < mesh.vertexCount; ++i)
{
newVertices[i] = reference[i % reference.Length] * 1.5f;
}
mesh.vertices = newVertices;
}
modified = true;
}
}
}