#define Graph_And_Chart_PRO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
namespace ChartAndGraph
{
public class RadarFill : MaskableGraphic
{
Material mCachedMaterial;
Vector3[] mPath;
Rect mPathRect;
public RadarFill()
{
}
///
/// sets the lines for this renderer
///
///
internal void SetPath(Vector3[] path,float radius)
{
mPath = path;
if (mPath.Length == 0)
mPath = null;
mPathRect = new Rect(-radius, -radius, radius * 2f, radius * 2f);
SetAllDirty();
Rebuild(CanvasUpdate.PreRender);
}
protected override void UpdateMaterial()
{
base.UpdateMaterial();
canvasRenderer.SetTexture(material.mainTexture);
}
protected override void OnDisable()
{
base.OnDisable();
ChartCommon.SafeDestroy(mCachedMaterial);
}
public override Material material
{
get
{
return base.material;
}
set
{
ChartCommon.SafeDestroy(mCachedMaterial);
if (value == null)
{
mCachedMaterial = null;
base.material = null;
return;
}
mCachedMaterial = new Material(value);
mCachedMaterial.hideFlags = HideFlags.DontSave;
base.material = mCachedMaterial;
}
}
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);
}
IEnumerable getVerices()
{
if (mPath == null)
yield break;
UIVertex origin = new UIVertex();
origin.position = new Vector3();
origin.uv0 = InterpolateInViewRect(origin.position);
for (int i=0; i