private void ModifyVertices(List <UIVertex> vertices) { //print(vertices.Count); if (parameters == null) { return; } if (ChartUntils.NeedsToUpdateCaches(parameters.Length, startAngleDegree)) { ChartUntils.CacheSinesAndCosines(StartAngleDegree); } //1 get center point Vector3 centerPosition = (vertices[0].position + vertices[2].position) / 2f; //2 set xUnit and yUnit Vector3 xUnit = (centerPosition.x - vertices[0].position.x) * Vector3.right; Vector3 yUnit = (centerPosition.y - vertices[0].position.y) * Vector3.up; //3 set uv Vector2 centerUv = (vertices[0].uv0 + vertices[2].uv0) / 2f; Vector2 uUnit = (centerUv.x - vertices[0].uv0.x) * Vector3.right; Vector2 vUnit = (centerUv.y - vertices[0].uv0.y) * Vector3.up; //3 set color gradual change(any vertex,the result is same) Color outerMultipliedColor = ChartUntils.GetMultipliedColor(vertices[0].color, outerColor); Color innerMultipledColor = ChartUntils.GetMultipliedColor(vertices[0].color, innerColor); for (int i = 0; i < parameters.Length; i++) { float parmeter = parameters[i]; float cosine = ChartUntils.cacheCosines[i]; float sine = ChartUntils.cacheSines[i]; UIVertex outertmp = vertices[0]; float outerParmeter = parmeter * outerRatio; outertmp.position = centerPosition + (xUnit * cosine + yUnit * sine) * outerParmeter; outertmp.uv0 = centerUv + (uUnit * cosine + vUnit * sine) * outerParmeter; outertmp.color = outerMultipliedColor; tempOuterVertices.Add(outertmp); UIVertex innertmp = vertices[0]; float innerParmeter = parmeter * innerRatio; innertmp.position = centerPosition + (xUnit * cosine + yUnit * sine) * innerParmeter; innertmp.uv0 = centerUv + (uUnit * cosine + vUnit * sine) * innerParmeter; innertmp.color = innerMultipledColor; tempInnerVertices.Add(innertmp); } if (parameters.Length > 0) { tempOuterVertices.Add(tempOuterVertices[0]); tempInnerVertices.Add(tempInnerVertices[0]); } vertices.Clear(); if (outerRatio != 0f) { for (int i = 0; i < parameters.Length; i++) { vertices.Add(tempInnerVertices[i]); vertices.Add(tempOuterVertices[i]); vertices.Add(tempOuterVertices[i + 1]); } } if (innerRatio != 0f) { for (int i = 0; i < parameters.Length; i++) { vertices.Add(tempOuterVertices[i + 1]); vertices.Add(tempInnerVertices[i + 1]); vertices.Add(tempInnerVertices[i]); } } tempOuterVertices.Clear(); tempInnerVertices.Clear(); }
private void ModifyVertices(List <UIVertex> vertices) { if (parametersCount == 0) { return; } if (ChartUntils.NeedsToUpdateCaches(parametersCount, startAngleDegree)) { ChartUntils.CacheSinesAndCosines(StartAngleDegree); } //1 get center point Vector3 centerPosition = (vertices[0].position + vertices[2].position) / 2f; //2 set xUnit and yUnit Vector3 xUnit = (centerPosition.x - vertices[0].position.x) * Vector3.right; Vector3 yUnit = (centerPosition.y - vertices[0].position.y) * Vector3.up; //3 set uv Vector2 centerUv = (vertices[0].uv0 + vertices[2].uv0) / 2f; Vector2 uUnit = (centerUv.x - vertices[0].uv0.x) * Vector3.right; Vector2 vUnit = (centerUv.y - vertices[0].uv0.y) * Vector3.up; UIVertex startVertex = vertices[0]; vertices.Clear(); for (int j = 0; j < cricleCount; j++) { for (int i = 0; i < parametersCount; i++) { float parmeter = 1f; float cosine = ChartUntils.cacheCosines[i]; float sine = ChartUntils.cacheSines[i]; UIVertex outertmp = startVertex; float outerParmeter = parmeter * (defaultCurde - j * cricleDisInterval * 0.15f); outertmp.position = centerPosition + (xUnit * cosine + yUnit * sine) * outerParmeter; outertmp.uv0 = centerUv + (uUnit * cosine + vUnit * sine) * outerParmeter; tempOuterVertices.Add(outertmp); UIVertex innertmp = startVertex; float innerParmeter = parmeter * ((defaultCurde - lineCurde * 0.1f) - j * cricleDisInterval * 0.15f); innertmp.position = centerPosition + (xUnit * cosine + yUnit * sine) * innerParmeter; innertmp.uv0 = centerUv + (uUnit * cosine + vUnit * sine) * innerParmeter; tempInnerVertices.Add(innertmp); } if (parametersCount > 0) { tempOuterVertices.Add(tempOuterVertices[0]); tempInnerVertices.Add(tempInnerVertices[0]); } if (defaultCurde != 0f) { for (int i = 0; i < parametersCount; i++) { vertices.Add(tempInnerVertices[i]); vertices.Add(tempOuterVertices[i]); vertices.Add(tempOuterVertices[i + 1]); } } if ((defaultCurde - lineCurde * 0.1f) != 0f) { for (int i = 0; i < parametersCount; i++) { vertices.Add(tempOuterVertices[i + 1]); vertices.Add(tempInnerVertices[i + 1]); vertices.Add(tempInnerVertices[i]); } } tempOuterVertices.Clear(); tempInnerVertices.Clear(); } }