void Start() { // Model reference. Source.Polygon polygonSource = GetComponent <Source.Polygon>(); if (polygonSource != null) { polygon = polygonSource.polygon; } }
public void UpdatePointPositionsWithSource(Source.Polygon polygonSource) // Assuming unchanged point count { UpdatePointPositionsWithTransforms(polygonSource.points, polygonSource.coordinates); // Update sub-polygons if any. foreach (Transform eachChildTransform in polygonSource.gameObject.transform) { GameObject eachChildGameObject = eachChildTransform.gameObject; Source.Polygon eachChildPolygonSource = eachChildGameObject.GetComponent <Source.Polygon>(); if (eachChildPolygonSource != null) { eachChildPolygonSource.polygon.UpdatePointPositionsWithTransforms(eachChildPolygonSource.points, eachChildPolygonSource.coordinates); } } }
public static Polygon PolygonWithSource(Source.Polygon polygonSource) { Polygon rootPolygon = Polygon.PolygonWithPointTransforms(polygonSource.points, polygonSource.coordinates); // Collect sub-polygons if any. foreach (Transform eachChildTransform in polygonSource.gameObject.transform) { GameObject eachChildGameObject = eachChildTransform.gameObject; Source.Polygon eachChildPolygonSource = eachChildGameObject.GetComponent <Source.Polygon>(); if (eachChildPolygonSource != null) { Polygon eachSubPolygon = Polygon.PolygonWithSource(eachChildPolygonSource); rootPolygon.AddPolygon(eachSubPolygon); } } return(rootPolygon); }
void Awake() { polygonSource = GetComponent <Source.Polygon>(); meshFilter = GetComponent <MeshFilter>(); if (meshFilter == null) { Debug.LogWarning("No <b>MeshFilter</b> component on \"" + name + "\" (for <b>PolygonMesh</b> to use as output). Disabled <i>GameObject</i>."); gameObject.SetActive(false); } if (polygonSource != null) { polygon = polygonSource.polygon; } if (update == UpdateMode.Awake) { CreateMesh(); } }