Files
XCharts/Runtime/Component/Axis/AxisName.cs

109 lines
3.1 KiB
C#
Raw Normal View History

2019-07-13 16:38:38 +08:00
using System;
using UnityEngine;
2022-02-19 22:37:57 +08:00
namespace XCharts.Runtime
2019-07-13 16:38:38 +08:00
{
/// <summary>
/// the name of axis.
/// 坐标轴名称。
/// </summary>
2019-07-13 16:38:38 +08:00
[Serializable]
2021-11-23 13:20:07 +08:00
public class AxisName : ChildComponent
2019-07-13 16:38:38 +08:00
{
/// <summary>
/// the location of axis name.
/// 坐标轴名称显示位置。
/// </summary>
2019-07-13 16:38:38 +08:00
public enum Location
{
Start,
Middle,
End
}
[SerializeField] private bool m_Show;
[SerializeField] private string m_Name;
2022-01-22 21:08:26 +08:00
[SerializeField] private string m_Formatter;
2019-07-13 16:38:38 +08:00
[SerializeField] private Location m_Location;
2021-01-11 08:54:28 +08:00
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
2019-07-13 16:38:38 +08:00
/// <summary>
/// Whether to show axis name.
/// 是否显示坐标名称。
/// </summary>
public bool show
{
get { return m_Show; }
2021-01-11 08:54:28 +08:00
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
}
/// <summary>
/// the name of axis.
/// 坐标轴名称。
/// </summary>
public string name
{
get { return m_Name; }
2021-01-11 08:54:28 +08:00
set { if (PropertyUtil.SetClass(ref m_Name, value)) SetComponentDirty(); }
}
/// <summary>
2022-01-22 21:08:26 +08:00
/// The formatter of indicator's name.
/// 指示器名称显示的格式器。可用在雷达图。
/// </summary>
public string formatter
{
get { return m_Formatter; }
set { if (PropertyUtil.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
}
/// <summary>
/// Location of axis name.
/// 坐标轴名称显示位置。
/// </summary>
public Location location
{
get { return m_Location; }
2021-01-11 08:54:28 +08:00
set { if (PropertyUtil.SetStruct(ref m_Location, value)) SetComponentDirty(); }
}
2021-01-11 08:54:28 +08:00
/// <summary>
2021-01-11 08:54:28 +08:00
/// The text style of axis name.
/// 文本样式。
/// </summary>
2021-01-11 08:54:28 +08:00
public TextStyle textStyle
{
2021-01-11 08:54:28 +08:00
get { return m_TextStyle; }
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
}
2019-07-13 16:38:38 +08:00
public static AxisName defaultAxisName
{
get
{
return new AxisName()
{
m_Show = false,
m_Name = "axisName",
m_Location = Location.End,
2021-01-11 08:54:28 +08:00
m_TextStyle = new TextStyle(),
2019-07-13 16:38:38 +08:00
};
}
}
public AxisName Clone()
{
var axisName = new AxisName();
axisName.show = show;
axisName.name = name;
axisName.location = location;
2021-01-11 08:54:28 +08:00
axisName.textStyle.Copy(textStyle);
return axisName;
}
public void Copy(AxisName axisName)
{
show = axisName.show;
name = axisName.name;
location = axisName.location;
2021-01-11 08:54:28 +08:00
textStyle.Copy(axisName.textStyle);
}
2019-07-13 16:38:38 +08:00
}
}