Files
XCharts/Runtime/Component/Child/ArrowStyle.cs

92 lines
2.5 KiB
C#
Raw Normal View History

2021-01-11 08:54:28 +08:00
using System;
using UnityEngine;
2022-02-19 22:37:57 +08:00
namespace XCharts.Runtime
2021-01-11 08:54:28 +08:00
{
/// <summary>
/// </summary>
[Serializable]
2021-11-23 13:20:07 +08:00
public class ArrowStyle : ChildComponent
2021-01-11 08:54:28 +08:00
{
[SerializeField] private float m_Width = 10;
[SerializeField] private float m_Height = 15;
[SerializeField] private float m_Offset = 0;
[SerializeField] private float m_Dent = 3;
[SerializeField] private Color32 m_Color = Color.clear;
/// <summary>
/// The widht of arrow.
2022-03-24 08:37:06 +08:00
/// |箭头宽。
2021-01-11 08:54:28 +08:00
/// </summary>
public float width
{
get { return m_Width; }
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
}
/// <summary>
/// The height of arrow.
2022-03-24 08:37:06 +08:00
/// |箭头高。
2021-01-11 08:54:28 +08:00
/// </summary>
public float height
{
get { return m_Height; }
set { if (PropertyUtil.SetStruct(ref m_Height, value)) SetVerticesDirty(); }
}
/// <summary>
/// The offset of arrow.
2022-03-24 08:37:06 +08:00
/// |箭头偏移。
2021-01-11 08:54:28 +08:00
/// </summary>
public float offset
{
get { return m_Offset; }
set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetVerticesDirty(); }
}
/// <summary>
/// The dent of arrow.
2022-03-24 08:37:06 +08:00
/// |箭头的凹度。
2021-01-11 08:54:28 +08:00
/// </summary>
public float dent
{
get { return m_Dent; }
set { if (PropertyUtil.SetStruct(ref m_Dent, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of arrow.
2022-03-24 08:37:06 +08:00
/// |箭头颜色。
2021-01-11 08:54:28 +08:00
/// </summary>
public Color32 color
{
get { return m_Color; }
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
}
2021-11-23 13:20:07 +08:00
public ArrowStyle Clone()
2021-01-11 08:54:28 +08:00
{
2021-11-23 13:20:07 +08:00
var arrow = new ArrowStyle();
2021-01-11 08:54:28 +08:00
arrow.width = width;
arrow.height = height;
arrow.offset = offset;
arrow.dent = dent;
arrow.color = color;
return arrow;
}
2021-11-23 13:20:07 +08:00
public void Copy(ArrowStyle arrow)
2021-01-11 08:54:28 +08:00
{
width = arrow.width;
height = arrow.height;
offset = arrow.offset;
dent = arrow.dent;
color = arrow.color;
}
public Color32 GetColor(Color32 defaultColor)
{
2021-11-23 13:20:07 +08:00
if (ChartHelper.IsClearColor(color))
return defaultColor;
else
return color;
2021-01-11 08:54:28 +08:00
}
}
}