public Face Init(Transform parent, PlanetSettings settings, Directions direction, ShapeGenerator shapeGenerator) { planetSettings = settings; Direction = direction; this.shapeGenerator = shapeGenerator; if (parent != null) { transform.parent = parent; } if (meshFilter == null) { meshFilter = gameObject.AddComponent <MeshFilter>(); meshFilter.mesh = Mesh = new Mesh { name = "Procedural Face" }; } if (meshRenderer == null) { meshRenderer = gameObject.AddComponent <MeshRenderer>(); } meshGenerator = null; gameObject.name = direction.ToString(); return(this); }
public void UpdateMesh() { if (meshGenerator == null) { faceMeshData = new FaceMeshData { Direction = Direction, Resolution = planetSettings.MeshResolution, Offset = Offset, LevelOfDetail = LevelOfDetail }; meshGenerator = new FaceMeshGenerator(faceMeshData, shapeGenerator); } meshGenerator.UpdateMesh(Mesh); }