2019-10-10 09:01:16 +08:00
using System ;
2022-05-22 22:17:38 +08:00
using UnityEngine ;
2019-10-10 09:01:16 +08:00
2022-02-19 22:37:57 +08:00
namespace XCharts.Runtime
2019-10-10 09:01:16 +08:00
{
/// <summary>
/// Global parameter setting component. The default value can be used in general, and can be adjusted when necessary.
2022-03-24 08:37:06 +08:00
/// |全局参数设置组件。一般情况下可使用默认值,当有需要时可进行调整。
2019-10-10 09:01:16 +08:00
/// </summary>
[Serializable]
2022-02-25 08:10:09 +08:00
public class Settings : MainComponent
2019-10-10 09:01:16 +08:00
{
2022-02-25 08:10:09 +08:00
[SerializeField] private bool m_Show = true ;
2022-05-22 22:17:38 +08:00
[SerializeField] [ Range ( 1 , 20 ) ] protected int m_MaxPainter = 10 ;
2021-04-29 07:30:42 +08:00
[SerializeField] protected bool m_ReversePainter = false ;
2021-05-01 22:43:17 +08:00
[SerializeField] protected Material m_BasePainterMaterial ;
[SerializeField] protected Material m_SeriePainterMaterial ;
2022-06-24 22:17:01 +08:00
[SerializeField] protected Material m_UpperPainterMaterial ;
2021-05-01 22:43:17 +08:00
[SerializeField] protected Material m_TopPainterMaterial ;
2022-06-26 08:35:59 +08:00
[SerializeField] [ Range ( 1 , 10 ) ] protected float m_LineSmoothStyle = 2.5f ;
2022-05-22 22:17:38 +08:00
[SerializeField] [ Range ( 1f , 20 ) ] protected float m_LineSmoothness = 2f ;
[SerializeField] [ Range ( 0.5f , 20 ) ] protected float m_LineSegmentDistance = 3f ;
[SerializeField] [ Range ( 1 , 10 ) ] protected float m_CicleSmoothness = 2f ;
2021-03-05 08:56:55 +08:00
[SerializeField] protected float m_LegendIconLineWidth = 2 ;
[SerializeField] private float [ ] m_LegendIconCornerRadius = new float [ ] { 0.25f , 0.25f , 0.25f , 0.25f } ;
2022-07-05 21:43:09 +08:00
[SerializeField] [ Since ( "v3.1.0" ) ] protected float m_AxisMaxSplitNumber = 50 ;
2019-10-10 09:01:16 +08:00
2022-02-25 08:10:09 +08:00
public bool show { get { return m_Show ; } }
2021-01-11 08:54:28 +08:00
/// <summary>
/// max painter.
2022-03-24 08:37:06 +08:00
/// |设定的painter数量。
2021-01-11 08:54:28 +08:00
/// </summary>
public int maxPainter
{
get { return m_MaxPainter ; }
set { if ( PropertyUtil . SetStruct ( ref m_MaxPainter , value < 0 ? 1 : value ) ) SetVerticesDirty ( ) ; }
}
2019-10-10 09:01:16 +08:00
/// <summary>
2021-04-29 07:30:42 +08:00
/// Painter是否逆序。逆序时index大的serie最先绘制。
/// </summary>
public bool reversePainter
{
get { return m_ReversePainter ; }
set { if ( PropertyUtil . SetStruct ( ref m_ReversePainter , value ) ) SetVerticesDirty ( ) ; }
}
/// <summary>
2021-05-01 22:43:17 +08:00
/// Base Pointer 材质球, 设置后会影响Axis等。
/// </summary>
public Material basePainterMaterial
{
get { return m_BasePainterMaterial ; }
set { if ( PropertyUtil . SetClass ( ref m_BasePainterMaterial , value ) ) SetComponentDirty ( ) ; }
}
/// <summary>
/// Serie Pointer 材质球, 设置后会影响所有Serie。
/// </summary>
public Material seriePainterMaterial
{
get { return m_SeriePainterMaterial ; }
set { if ( PropertyUtil . SetClass ( ref m_SeriePainterMaterial , value ) ) SetComponentDirty ( ) ; }
}
/// <summary>
2022-06-24 22:17:01 +08:00
/// Top Pointer 材质球。
2021-05-01 22:43:17 +08:00
/// </summary>
public Material topPainterMaterial
{
get { return m_TopPainterMaterial ; }
set { if ( PropertyUtil . SetClass ( ref m_TopPainterMaterial , value ) ) SetComponentDirty ( ) ; }
}
/// <summary>
2022-06-24 22:17:01 +08:00
/// Upper Pointer 材质球。
/// </summary>
public Material upperPainterMaterial
{
get { return m_UpperPainterMaterial ; }
set { if ( PropertyUtil . SetClass ( ref m_UpperPainterMaterial , value ) ) SetComponentDirty ( ) ; }
}
/// <summary>
2019-10-10 09:01:16 +08:00
/// Curve smoothing factor. By adjusting the smoothing coefficient, the curvature of the curve can be changed,
/// and different curves with slightly different appearance can be obtained.
2022-03-24 08:37:06 +08:00
/// |曲线平滑系数。通过调整平滑系数可以改变曲线的曲率,得到外观稍微有变化的不同曲线。
2019-10-10 09:01:16 +08:00
/// </summary>
2020-03-05 20:25:19 +08:00
public float lineSmoothStyle
{
get { return m_LineSmoothStyle ; }
2021-01-11 08:54:28 +08:00
set { if ( PropertyUtil . SetStruct ( ref m_LineSmoothStyle , value < 0 ? 1f : value ) ) SetVerticesDirty ( ) ; }
2020-03-05 20:25:19 +08:00
}
2019-10-10 09:01:16 +08:00
/// <summary>
2022-03-24 08:37:06 +08:00
/// Smoothness of curve. The smaller the value, the smoother the curve, but the number of vertices will increase.
/// |When the area with gradient is filled, the larger the value, the worse the transition effect.
/// |曲线平滑度。值越小曲线越平滑,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
2019-10-10 09:01:16 +08:00
/// </summary>
/// <value></value>
2020-03-05 20:25:19 +08:00
public float lineSmoothness
{
get { return m_LineSmoothness ; }
2021-01-11 08:54:28 +08:00
set { if ( PropertyUtil . SetStruct ( ref m_LineSmoothStyle , value < 0 ? 1f : value ) ) SetVerticesDirty ( ) ; }
2020-03-05 20:25:19 +08:00
}
2019-10-10 09:01:16 +08:00
/// <summary>
/// The partition distance of a line segment. A line in a normal line chart is made up of many segments,
/// the number of which is determined by the change in value. The smaller the number of segments,
/// the higher the number of vertices. When the area with gradient is filled, the larger the value, the worse the transition effect.
2022-03-24 08:37:06 +08:00
/// |线段的分割距离。普通折线图的线是由很多线段组成,段数由该数值决定。值越小段数越多,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
2019-10-10 09:01:16 +08:00
/// </summary>
/// <value></value>
2020-03-05 20:25:19 +08:00
public float lineSegmentDistance
{
get { return m_LineSegmentDistance ; }
2021-01-11 08:54:28 +08:00
set { if ( PropertyUtil . SetStruct ( ref m_LineSegmentDistance , value < 0 ? 1f : value ) ) SetVerticesDirty ( ) ; }
2020-03-05 20:25:19 +08:00
}
2019-10-10 09:01:16 +08:00
/// <summary>
/// the smoothess of cricle.
2022-03-24 08:37:06 +08:00
/// |圆形的平滑度。数越小圆越平滑,但顶点数也会随之增加。
2019-10-10 09:01:16 +08:00
/// </summary>
2020-03-05 20:25:19 +08:00
public float cicleSmoothness
{
get { return m_CicleSmoothness ; }
2021-01-11 08:54:28 +08:00
set { if ( PropertyUtil . SetStruct ( ref m_CicleSmoothness , value < 0 ? 1f : value ) ) SetVerticesDirty ( ) ; }
2020-03-05 20:25:19 +08:00
}
2021-01-11 08:54:28 +08:00
2021-03-05 08:56:55 +08:00
/// <summary>
/// the width of line serie legend.
2022-03-24 08:37:06 +08:00
/// |Line类型图例图标的线条宽度。
2021-03-05 08:56:55 +08:00
/// </summary>
public float legendIconLineWidth
{
get { return m_LegendIconLineWidth ; }
set { if ( PropertyUtil . SetStruct ( ref m_LegendIconLineWidth , value ) ) SetVerticesDirty ( ) ; }
}
/// <summary>
/// The radius of rounded corner. Its unit is px. Use array to respectively specify the 4 corner radiuses((clockwise upper left, upper right, bottom right and bottom left)).
2022-03-24 08:37:06 +08:00
/// |图例圆角半径。用数组分别指定4个圆角半径( 顺时针左上, 右上, 右下, 左下) 。
2021-03-05 08:56:55 +08:00
/// </summary>
public float [ ] legendIconCornerRadius
{
get { return m_LegendIconCornerRadius ; }
set { if ( PropertyUtil . SetClass ( ref m_LegendIconCornerRadius , value , true ) ) SetVerticesDirty ( ) ; }
}
2022-07-04 13:37:16 +08:00
/// <summary>
/// the max splitnumber of axis.
/// |坐标轴最大分隔段数。段数过大时可能会生成较多的label节点。
/// </summary>
public float axisMaxSplitNumber
{
get { return m_AxisMaxSplitNumber ; }
set { if ( PropertyUtil . SetStruct ( ref m_AxisMaxSplitNumber , value ) ) SetVerticesDirty ( ) ; }
}
2021-01-11 08:54:28 +08:00
public void Copy ( Settings settings )
2020-03-05 20:25:19 +08:00
{
2021-04-29 07:30:42 +08:00
m_ReversePainter = settings . reversePainter ;
2021-01-11 08:54:28 +08:00
m_MaxPainter = settings . maxPainter ;
2021-05-01 22:43:17 +08:00
m_BasePainterMaterial = settings . basePainterMaterial ;
m_SeriePainterMaterial = settings . seriePainterMaterial ;
2022-06-24 22:17:01 +08:00
m_UpperPainterMaterial = settings . upperPainterMaterial ;
2021-05-01 22:43:17 +08:00
m_TopPainterMaterial = settings . topPainterMaterial ;
2021-01-11 08:54:28 +08:00
m_LineSmoothStyle = settings . lineSmoothStyle ;
m_LineSmoothness = settings . lineSmoothness ;
m_LineSegmentDistance = settings . lineSegmentDistance ;
m_CicleSmoothness = settings . cicleSmoothness ;
2021-03-05 08:56:55 +08:00
m_LegendIconLineWidth = settings . legendIconLineWidth ;
ChartHelper . CopyArray ( m_LegendIconCornerRadius , settings . legendIconCornerRadius ) ;
2020-03-05 20:25:19 +08:00
}
2021-01-11 08:54:28 +08:00
2022-02-25 08:10:09 +08:00
public override void Reset ( )
2020-03-05 20:25:19 +08:00
{
2021-01-11 08:54:28 +08:00
Copy ( DefaultSettings ) ;
2020-03-05 20:25:19 +08:00
}
2021-01-11 08:54:28 +08:00
public static Settings DefaultSettings
2020-03-05 20:25:19 +08:00
{
2021-01-11 08:54:28 +08:00
get
{
return new Settings ( )
{
2021-04-29 07:30:42 +08:00
m_ReversePainter = false ,
2022-05-22 22:17:38 +08:00
m_MaxPainter = XCSettings . maxPainter ,
m_LineSmoothStyle = XCSettings . lineSmoothStyle ,
m_LineSmoothness = XCSettings . lineSmoothness ,
m_LineSegmentDistance = XCSettings . lineSegmentDistance ,
m_CicleSmoothness = XCSettings . cicleSmoothness ,
m_LegendIconLineWidth = 2 ,
m_LegendIconCornerRadius = new float [ ] { 0.25f , 0.25f , 0.25f , 0.25f }
2021-01-11 08:54:28 +08:00
} ;
}
2020-03-05 20:25:19 +08:00
}
2019-10-10 09:01:16 +08:00
}
}