-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractSurfaceRenderer.cs
More file actions
39 lines (29 loc) · 963 Bytes
/
AbstractSurfaceRenderer.cs
File metadata and controls
39 lines (29 loc) · 963 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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class AbstractSurfaceRenderer: MonoBehaviour{
protected AbstractSurface _surface;
protected Mesh _mesh;
protected List<Vector3> _vertices;
protected List<int> _triangles;
protected List<Color32> _colors;
public void Awake(){
gameObject.AddComponent<MeshFilter> ();
gameObject.AddComponent<MeshRenderer> ().material = new Material (Shader.Find ("vertexShader"));
_mesh = GetComponent<MeshFilter> ().mesh;
}
public void setSurface(AbstractSurface m){
_surface = m;
}
public void Update(){
render();
}
public abstract void readyRender();
public void render(){
readyRender();
_mesh.SetVertices(_vertices);
_mesh.SetTriangles(_triangles, 0, false);
_mesh.SetColors(_colors);
System.GC.Collect();
}
}