增加RadarCoordstartAngle可设置Radar起始角度

This commit is contained in:
monitor1394
2022-10-26 08:04:44 +08:00
parent 42a77a9439
commit ce4e88c51c
7 changed files with 34 additions and 14 deletions

View File

@@ -108,6 +108,7 @@ namespace XCharts.Runtime
[SerializeField] private Color32 m_OutRangeColor = Color.red;
[SerializeField] private bool m_ConnectCenter = false;
[SerializeField] private bool m_LineGradient = true;
[SerializeField][Since("v3.4.0")] private float m_StartAngle;
[SerializeField] private List<Indicator> m_IndicatorList = new List<Indicator>();
public RadarCoordContext context = new RadarCoordContext();
@@ -264,6 +265,14 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_LineGradient, value)) SetAllDirty(); }
}
/// <summary>
/// 起始角度。和时钟一样12点钟位置是0度顺时针到360度。
/// </summary>
public float startAngle
{
get { return m_StartAngle; }
set { if (PropertyUtil.SetStruct(ref m_StartAngle, value)) SetVerticesDirty(); }
}
/// <summary>
/// the indicator list.
/// |指示器列表。
/// </summary>

View File

@@ -124,7 +124,8 @@ namespace XCharts.Runtime
int indicatorNum = radar.indicatorList.Count;
Vector3 p1, p2, p3, p4;
Vector3 p = radar.context.center;
float angle = 2 * Mathf.PI / indicatorNum;
var startAngle = radar.startAngle * Mathf.PI / 180;
var angle = 2 * Mathf.PI / indicatorNum;
var lineColor = radar.axisLine.GetColor(chart.theme.axis.splitLineColor);
var lineWidth = radar.axisLine.GetWidth(chart.theme.axis.lineWidth);
var lineType = radar.axisLine.GetType(chart.theme.axis.lineType);
@@ -135,11 +136,11 @@ namespace XCharts.Runtime
{
var color = radar.splitArea.GetColor(i, chart.theme.axis);
outsideRadius = insideRadius + block;
p1 = new Vector3(p.x + insideRadius * Mathf.Sin(0), p.y + insideRadius * Mathf.Cos(0));
p2 = new Vector3(p.x + outsideRadius * Mathf.Sin(0), p.y + outsideRadius * Mathf.Cos(0));
p1 = new Vector3(p.x + insideRadius * Mathf.Sin(startAngle), p.y + insideRadius * Mathf.Cos(startAngle));
p2 = new Vector3(p.x + outsideRadius * Mathf.Sin(startAngle), p.y + outsideRadius * Mathf.Cos(startAngle));
for (int j = 0; j <= indicatorNum; j++)
{
float currAngle = j * angle;
float currAngle = startAngle + j * angle;
p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
p.y + outsideRadius * Mathf.Cos(currAngle));
p4 = new Vector3(p.x + insideRadius * Mathf.Sin(currAngle),
@@ -161,7 +162,7 @@ namespace XCharts.Runtime
{
for (int j = 0; j <= indicatorNum; j++)
{
float currAngle = j * angle;
float currAngle = startAngle + j * angle;
p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
p.y + outsideRadius * Mathf.Cos(currAngle));
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, p, p3, lineColor);