private void Awake() { BezierToVertex = new BezierToVertex(); BezierToVertex.WorkBufferPool = WorkBufferPool; Triangulation = new Triangulation(); Triangulation.WorkBufferPool = WorkBufferPool; }
protected override void OnPopulateMesh(VertexHelper vh) { if (_bezierToVertex == null) { _bezierToVertex = new BezierToVertex { WorkBufferPool = _workBufferPool, Scale = 1 } } ; if (_triangulation == null) { _triangulation = new Triangulation { Delaunay = false, Interior = true, Exterior = false, Infinity = false, WorkBufferPool = _workBufferPool } } ; var selfRectTransform = (RectTransform)transform; var selfRect = selfRectTransform.rect; var offset = new Vector2(-selfRectTransform.pivot.x * selfRect.width, (1 - selfRectTransform.pivot.y) * selfRect.height); var svgData = BuildWave(selfRect, _waveCenterY * selfRect.height, _waveHorRadius * selfRect.width, _waveVertRadius * selfRect.height, _sideWidth * selfRect.width); _meshData.Clear(); _bezierToVertex.GetContours(svgData, _meshData); _triangulation.BuildTriangles(_meshData); _meshData.MakeUnityFriendly(); _meshData.Upload(vh, offset, color); }