2019-11-30 21:24:04 +08:00
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2022-02-19 22:37:57 +08:00
|
|
|
namespace XCharts.Runtime
|
2019-11-30 21:24:04 +08:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// the title of serie.
|
2022-03-24 08:37:06 +08:00
|
|
|
/// |标题相关设置。
|
2019-11-30 21:24:04 +08:00
|
|
|
/// </summary>
|
|
|
|
|
[Serializable]
|
2022-02-19 17:35:22 +08:00
|
|
|
public class TitleStyle : ChildComponent, ISerieDataComponent, ISerieExtraComponent
|
2019-11-30 21:24:04 +08:00
|
|
|
{
|
2022-02-19 17:35:22 +08:00
|
|
|
[SerializeField] private bool m_Show = true;
|
|
|
|
|
[SerializeField] private Vector2 m_OffsetCenter = new Vector2(0, -0.2f);
|
2021-01-11 08:54:28 +08:00
|
|
|
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
2019-11-30 21:24:04 +08:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether to show title.
|
2022-03-24 08:37:06 +08:00
|
|
|
/// |是否显示标题。
|
2019-11-30 21:24:04 +08:00
|
|
|
/// </summary>
|
2020-03-08 10:47:48 +08:00
|
|
|
public bool show
|
|
|
|
|
{
|
|
|
|
|
get { return m_Show; }
|
2021-01-11 08:54:28 +08:00
|
|
|
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
2020-03-08 10:47:48 +08:00
|
|
|
}
|
2022-02-19 17:35:22 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// The offset position relative to the center.
|
2022-03-24 08:37:06 +08:00
|
|
|
/// |相对于中心的偏移位置。
|
2022-02-19 17:35:22 +08:00
|
|
|
/// </summary>
|
|
|
|
|
public Vector2 offsetCenter
|
|
|
|
|
{
|
|
|
|
|
get { return m_OffsetCenter; }
|
|
|
|
|
set { if (PropertyUtil.SetStruct(ref m_OffsetCenter, value)) SetComponentDirty(); }
|
|
|
|
|
}
|
2019-11-30 21:24:04 +08:00
|
|
|
|
|
|
|
|
/// <summary>
|
2022-03-24 08:37:06 +08:00
|
|
|
/// the color of text.
|
|
|
|
|
/// |文本的颜色。
|
2019-11-30 21:24:04 +08:00
|
|
|
/// </summary>
|
2020-03-08 10:47:48 +08:00
|
|
|
public TextStyle textStyle
|
2019-11-30 21:24:04 +08:00
|
|
|
{
|
2020-03-08 10:47:48 +08:00
|
|
|
get { return m_TextStyle; }
|
2021-01-11 08:54:28 +08:00
|
|
|
set { if (PropertyUtil.SetClass(ref m_TextStyle, value, true)) SetComponentDirty(); }
|
2019-11-30 21:24:04 +08:00
|
|
|
}
|
|
|
|
|
|
2020-03-08 10:47:48 +08:00
|
|
|
public override bool componentDirty { get { return m_ComponentDirty || textStyle.componentDirty; } }
|
2019-11-30 21:24:04 +08:00
|
|
|
|
2021-05-16 23:38:06 +08:00
|
|
|
public override void ClearComponentDirty()
|
2019-11-30 21:24:04 +08:00
|
|
|
{
|
2020-03-08 10:47:48 +08:00
|
|
|
base.ClearComponentDirty();
|
|
|
|
|
textStyle.ClearComponentDirty();
|
2019-11-30 21:24:04 +08:00
|
|
|
}
|
|
|
|
|
|
2022-02-19 17:35:22 +08:00
|
|
|
public Vector3 GetOffset(float radius)
|
2021-03-25 12:55:52 +08:00
|
|
|
{
|
2022-02-19 17:35:22 +08:00
|
|
|
var x = ChartHelper.GetActualValue(m_OffsetCenter.x, radius);
|
|
|
|
|
var y = ChartHelper.GetActualValue(m_OffsetCenter.y, radius);
|
|
|
|
|
return new Vector3(x, y, 0);
|
2021-03-25 12:55:52 +08:00
|
|
|
}
|
2019-11-30 21:24:04 +08:00
|
|
|
}
|
|
|
|
|
}
|