#define Graph_And_Chart_PRO using System; using System.Collections.Generic; using System.Linq; using System.Text; using UnityEngine; namespace ChartAndGraph { [RequireComponent(typeof(MeshRenderer))] [RequireComponent(typeof(MeshFilter))] public class RadarFillGenerator : MonoBehaviour { public int Smoothing = 3; /// /// Contains a mesh that was generate for this object only and should be destoryed once the object is cleaned /// Mesh mCleanMesh = null; /// /// the mesh filter for this object /// MeshFilter mFilter; Vector3[] mPath; Rect mPathRect; float mCurve; private bool EnsureMeshFilter() { if (mFilter == null) mFilter = GetComponent(); if (mFilter == null) return false; return true; } Vector2 InterpolateInViewRect(Vector3 position) { float x = position.x - mPathRect.xMin; float y = position.y - mPathRect.yMin; return new Vector2(x / mPathRect.width, y / mPathRect.height); } Vector3 curve(Vector3 origin,Vector3 end,float t) { Vector3 cont = Vector3.Lerp(origin, end, 0.5f); cont.z *= 1.5f; float invT = 1f - t; return (invT * invT * origin) + (2 * invT * t * cont) + (t * t * end); } IEnumerable getVerices() { if (mPath == null) yield break; UIVertex origin = new UIVertex(); origin.position = new Vector3(); origin.position.z = mCurve; origin.uv0 = InterpolateInViewRect(origin.position); for (int i = 0; i < mPath.Length; i++) { UIVertex current = new UIVertex(); current.position = mPath[i]; current.uv0 = InterpolateInViewRect(current.position); for(int j=0; j