Fist Sub
based on aimbot multi seane
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// The style of area.
|
||||
/// |区域填充样式。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class AreaStyle : ChildComponent, ISerieExtraComponent, ISerieDataComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Origin position of area.
|
||||
/// |图形区域的起始位置。默认情况下,图形会从坐标轴轴线到数据间进行填充。如果需要填充的区域是坐标轴最大值到数据间,或者坐标轴最小值到数据间,则可以通过这个配置项进行设置。
|
||||
/// </summary>
|
||||
public enum AreaOrigin
|
||||
{
|
||||
/// <summary>
|
||||
/// to fill between axis line to data.
|
||||
/// |填充坐标轴轴线到数据间的区域。
|
||||
/// </summary>
|
||||
Auto,
|
||||
/// <summary>
|
||||
/// to fill between min axis value (when not inverse) to data.
|
||||
/// |填充坐标轴底部到数据间的区域。
|
||||
/// </summary>
|
||||
Start,
|
||||
/// <summary>
|
||||
/// to fill between max axis value (when not inverse) to data.
|
||||
/// |填充坐标轴顶部到数据间的区域。
|
||||
/// </summary>
|
||||
End
|
||||
}
|
||||
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private AreaOrigin m_Origin;
|
||||
[SerializeField] private Color32 m_Color;
|
||||
[SerializeField] private Color32 m_ToColor;
|
||||
[SerializeField][Range(0, 1)] private float m_Opacity = 0.6f;
|
||||
[SerializeField] private Color32 m_HighlightColor;
|
||||
[SerializeField] private Color32 m_HighlightToColor;
|
||||
|
||||
/// <summary>
|
||||
/// Set this to false to prevent the areafrom showing.
|
||||
/// |是否显示区域填充。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the origin of area.
|
||||
/// |区域填充的起始位置。
|
||||
/// </summary>
|
||||
public AreaOrigin origin
|
||||
{
|
||||
get { return m_Origin; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Origin, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of area,default use serie color.
|
||||
/// |区域填充的颜色,如果toColor不是默认值,则表示渐变色的起点颜色。
|
||||
/// </summary>
|
||||
public Color32 color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gradient color, start color to toColor.
|
||||
/// |渐变色的终点颜色。
|
||||
/// </summary>
|
||||
public Color32 toColor
|
||||
{
|
||||
get { return m_ToColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Opacity of the component. Supports value from 0 to 1, and the component will not be drawn when set to 0.
|
||||
/// |图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|
||||
/// </summary>
|
||||
public float opacity
|
||||
{
|
||||
get { return m_Opacity; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of area,default use serie color.
|
||||
/// |高亮时区域填充的颜色,如果highlightToColor不是默认值,则表示渐变色的起点颜色。
|
||||
/// </summary>
|
||||
public Color32 highlightColor
|
||||
{
|
||||
get { return m_HighlightColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_HighlightColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gradient color, start highlightColor to highlightToColor.
|
||||
/// |高亮时渐变色的终点颜色。
|
||||
/// </summary>
|
||||
public Color32 highlightToColor
|
||||
{
|
||||
get { return m_HighlightToColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_HighlightToColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public Color32 GetColor()
|
||||
{
|
||||
if (m_Opacity == 1)
|
||||
return m_Color;
|
||||
|
||||
var color = m_Color;
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
public Color32 GetColor(Color32 themeColor)
|
||||
{
|
||||
if (!ChartHelper.IsClearColor(color))
|
||||
{
|
||||
return GetColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
var color = themeColor;
|
||||
color.a = (byte) (color.a * opacity);
|
||||
return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec0d95a9298bb4c159dcae36020beec9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ArrowStyle : ChildComponent
|
||||
{
|
||||
[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.
|
||||
/// |箭头宽。
|
||||
/// </summary>
|
||||
public float width
|
||||
{
|
||||
get { return m_Width; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The height of arrow.
|
||||
/// |箭头高。
|
||||
/// </summary>
|
||||
public float height
|
||||
{
|
||||
get { return m_Height; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Height, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The offset of arrow.
|
||||
/// |箭头偏移。
|
||||
/// </summary>
|
||||
public float offset
|
||||
{
|
||||
get { return m_Offset; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The dent of arrow.
|
||||
/// |箭头的凹度。
|
||||
/// </summary>
|
||||
public float dent
|
||||
{
|
||||
get { return m_Dent; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Dent, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the color of arrow.
|
||||
/// |箭头颜色。
|
||||
/// </summary>
|
||||
public Color32 color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public ArrowStyle Clone()
|
||||
{
|
||||
var arrow = new ArrowStyle();
|
||||
arrow.width = width;
|
||||
arrow.height = height;
|
||||
arrow.offset = offset;
|
||||
arrow.dent = dent;
|
||||
arrow.color = color;
|
||||
return arrow;
|
||||
}
|
||||
|
||||
public void Copy(ArrowStyle arrow)
|
||||
{
|
||||
width = arrow.width;
|
||||
height = arrow.height;
|
||||
offset = arrow.offset;
|
||||
dent = arrow.dent;
|
||||
color = arrow.color;
|
||||
}
|
||||
|
||||
public Color32 GetColor(Color32 defaultColor)
|
||||
{
|
||||
if (ChartHelper.IsClearColor(color))
|
||||
return defaultColor;
|
||||
else
|
||||
return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2232b812c68f042d29c44863e38d0417
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,82 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// Settings related to base line.
|
||||
/// |线条基础配置。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class BaseLine : ChildComponent
|
||||
{
|
||||
[SerializeField] protected bool m_Show;
|
||||
[SerializeField] protected LineStyle m_LineStyle = new LineStyle();
|
||||
|
||||
/// <summary>
|
||||
/// Set this to false to prevent the axis line from showing.
|
||||
/// |是否显示坐标轴轴线。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 线条样式
|
||||
/// </summary>
|
||||
public LineStyle lineStyle
|
||||
{
|
||||
get { return m_LineStyle; }
|
||||
set { if (value != null) { m_LineStyle = value; SetVerticesDirty(); } }
|
||||
}
|
||||
|
||||
public static BaseLine defaultBaseLine
|
||||
{
|
||||
get
|
||||
{
|
||||
var axisLine = new BaseLine
|
||||
{
|
||||
m_Show = true,
|
||||
m_LineStyle = new LineStyle()
|
||||
};
|
||||
return axisLine;
|
||||
}
|
||||
}
|
||||
|
||||
public BaseLine()
|
||||
{
|
||||
lineStyle = new LineStyle();
|
||||
}
|
||||
|
||||
public BaseLine(bool show) : base()
|
||||
{
|
||||
m_Show = show;
|
||||
}
|
||||
|
||||
public void Copy(BaseLine axisLine)
|
||||
{
|
||||
show = axisLine.show;
|
||||
lineStyle.Copy(axisLine.lineStyle);
|
||||
}
|
||||
|
||||
public LineStyle.Type GetType(LineStyle.Type themeType)
|
||||
{
|
||||
return lineStyle.GetType(themeType);
|
||||
}
|
||||
|
||||
public float GetWidth(float themeWidth)
|
||||
{
|
||||
return lineStyle.GetWidth(themeWidth);
|
||||
}
|
||||
|
||||
public float GetLength(float themeLength)
|
||||
{
|
||||
return lineStyle.GetLength(themeLength);
|
||||
}
|
||||
|
||||
public Color32 GetColor(Color32 themeColor)
|
||||
{
|
||||
return lineStyle.GetColor(themeColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c431b00ccffe4db4b61179b6df06eb2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,118 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[System.Serializable]
|
||||
public class IconStyle : ChildComponent
|
||||
{
|
||||
public enum Layer
|
||||
{
|
||||
/// <summary>
|
||||
/// The icon is display under the label text.
|
||||
/// 图标在标签文字下
|
||||
/// </summary>
|
||||
UnderText,
|
||||
/// <summary>
|
||||
/// The icon is display above the label text.
|
||||
/// 图标在标签文字上
|
||||
/// </summary>
|
||||
AboveText
|
||||
}
|
||||
|
||||
[SerializeField] private bool m_Show = false;
|
||||
[SerializeField] private Layer m_Layer;
|
||||
[SerializeField] private Align m_Align = Align.Left;
|
||||
[SerializeField] private Sprite m_Sprite;
|
||||
[SerializeField] private Image.Type m_Type;
|
||||
[SerializeField] private Color m_Color = Color.white;
|
||||
[SerializeField] private float m_Width = 20;
|
||||
[SerializeField] private float m_Height = 20;
|
||||
[SerializeField] private Vector3 m_Offset;
|
||||
[SerializeField] private bool m_AutoHideWhenLabelEmpty = false;
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
m_Show = false;
|
||||
m_Layer = Layer.UnderText;
|
||||
m_Sprite = null;
|
||||
m_Color = Color.white;
|
||||
m_Width = 20;
|
||||
m_Height = 20;
|
||||
m_Offset = Vector3.zero;
|
||||
m_AutoHideWhenLabelEmpty = false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether the data icon is show.
|
||||
/// |是否显示图标。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// 显示在上层还是在下层。
|
||||
/// </summary>
|
||||
public Layer layer { get { return m_Layer; } set { m_Layer = value; } }
|
||||
/// <summary>
|
||||
/// The image of icon.
|
||||
/// |图标的图片。
|
||||
/// </summary>
|
||||
public Sprite sprite { get { return m_Sprite; } set { m_Sprite = value; } }
|
||||
/// <summary>
|
||||
/// How to display the icon.
|
||||
/// |图片的显示类型。
|
||||
/// </summary>
|
||||
public Image.Type type { get { return m_Type; } set { m_Type = value; } }
|
||||
/// <summary>
|
||||
/// 图标颜色。
|
||||
/// </summary>
|
||||
public Color color { get { return m_Color; } set { m_Color = value; } }
|
||||
/// <summary>
|
||||
/// 图标宽。
|
||||
/// </summary>
|
||||
public float width { get { return m_Width; } set { m_Width = value; } }
|
||||
/// <summary>
|
||||
/// 图标高。
|
||||
/// </summary>
|
||||
public float height { get { return m_Height; } set { m_Height = value; } }
|
||||
/// <summary>
|
||||
/// 图标偏移。
|
||||
/// </summary>
|
||||
public Vector3 offset { get { return m_Offset; } set { m_Offset = value; } }
|
||||
/// <summary>
|
||||
/// 水平方向对齐方式。
|
||||
/// </summary>
|
||||
public Align align { get { return m_Align; } set { m_Align = value; } }
|
||||
/// <summary>
|
||||
/// 当label内容为空时是否自动隐藏图标
|
||||
/// </summary>
|
||||
public bool autoHideWhenLabelEmpty { get { return m_AutoHideWhenLabelEmpty; } set { m_AutoHideWhenLabelEmpty = value; } }
|
||||
public IconStyle Clone()
|
||||
{
|
||||
var iconStyle = new IconStyle();
|
||||
iconStyle.show = show;
|
||||
iconStyle.layer = layer;
|
||||
iconStyle.sprite = sprite;
|
||||
iconStyle.type = type;
|
||||
iconStyle.color = color;
|
||||
iconStyle.width = width;
|
||||
iconStyle.height = height;
|
||||
iconStyle.offset = offset;
|
||||
iconStyle.align = align;
|
||||
iconStyle.autoHideWhenLabelEmpty = autoHideWhenLabelEmpty;
|
||||
return iconStyle;
|
||||
}
|
||||
|
||||
public void Copy(IconStyle iconStyle)
|
||||
{
|
||||
show = iconStyle.show;
|
||||
layer = iconStyle.layer;
|
||||
sprite = iconStyle.sprite;
|
||||
type = iconStyle.type;
|
||||
color = iconStyle.color;
|
||||
width = iconStyle.width;
|
||||
height = iconStyle.height;
|
||||
offset = iconStyle.offset;
|
||||
align = iconStyle.align;
|
||||
autoHideWhenLabelEmpty = iconStyle.autoHideWhenLabelEmpty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82c4d360f7b5b4ee7845e9bbe611c8a3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,81 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[System.Serializable]
|
||||
public class ImageStyle : ChildComponent, ISerieExtraComponent, ISerieDataComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private Sprite m_Sprite;
|
||||
[SerializeField] private Image.Type m_Type;
|
||||
[SerializeField] private bool m_AutoColor;
|
||||
[SerializeField] private Color m_Color = Color.clear;
|
||||
[SerializeField] private float m_Width = 0;
|
||||
[SerializeField] private float m_Height = 0;
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
m_Show = false;
|
||||
m_Type = Image.Type.Simple;
|
||||
m_Sprite = null;
|
||||
m_AutoColor = false;
|
||||
m_Color = Color.white;
|
||||
m_Width = 0;
|
||||
m_Height = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the data icon is show.
|
||||
/// |是否显示图标。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// The image of icon.
|
||||
/// |图标的图片。
|
||||
/// </summary>
|
||||
public Sprite sprite { get { return m_Sprite; } set { m_Sprite = value; } }
|
||||
/// <summary>
|
||||
/// How to display the image.
|
||||
/// |图片的显示类型。
|
||||
/// </summary>
|
||||
public Image.Type type { get { return m_Type; } set { m_Type = value; } }
|
||||
/// <summary>
|
||||
/// 是否自动颜色。
|
||||
/// </summary>
|
||||
public bool autoColor { get { return m_AutoColor; } set { m_AutoColor = value; } }
|
||||
/// <summary>
|
||||
/// 图标颜色。
|
||||
/// </summary>
|
||||
public Color color { get { return m_Color; } set { m_Color = value; } }
|
||||
/// <summary>
|
||||
/// 图标宽。
|
||||
/// </summary>
|
||||
public float width { get { return m_Width; } set { m_Width = value; } }
|
||||
/// <summary>
|
||||
/// 图标高。
|
||||
/// </summary>
|
||||
public float height { get { return m_Height; } set { m_Height = value; } }
|
||||
public ImageStyle Clone()
|
||||
{
|
||||
var imageStyle = new ImageStyle();
|
||||
imageStyle.type = type;
|
||||
imageStyle.sprite = sprite;
|
||||
imageStyle.autoColor = autoColor;
|
||||
imageStyle.color = color;
|
||||
imageStyle.width = width;
|
||||
imageStyle.height = height;
|
||||
return imageStyle;
|
||||
}
|
||||
|
||||
public void Copy(ImageStyle imageStyle)
|
||||
{
|
||||
type = imageStyle.type;
|
||||
sprite = imageStyle.sprite;
|
||||
autoColor = imageStyle.autoColor;
|
||||
color = imageStyle.color;
|
||||
width = imageStyle.width;
|
||||
height = imageStyle.height;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a76d1129783c4f55b0773da2eda9b67
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,350 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 图形样式。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class ItemStyle : ChildComponent, ISerieDataComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private Color32 m_Color;
|
||||
[SerializeField] private Color32 m_Color0;
|
||||
[SerializeField] private Color32 m_ToColor;
|
||||
[SerializeField] private Color32 m_ToColor2;
|
||||
[SerializeField] private Color32 m_BackgroundColor;
|
||||
[SerializeField] private float m_BackgroundWidth;
|
||||
[SerializeField] private Color32 m_CenterColor;
|
||||
[SerializeField] private float m_CenterGap;
|
||||
[SerializeField] private float m_BorderWidth = 0;
|
||||
[SerializeField] private float m_BorderGap = 0;
|
||||
[SerializeField] private Color32 m_BorderColor;
|
||||
[SerializeField] private Color32 m_BorderColor0;
|
||||
[SerializeField] private Color32 m_BorderToColor;
|
||||
[SerializeField][Range(0, 1)] private float m_Opacity = 1;
|
||||
[SerializeField] private string m_ItemMarker;
|
||||
[SerializeField] private string m_ItemFormatter;
|
||||
[SerializeField] private string m_NumericFormatter = "";
|
||||
[SerializeField] private float[] m_CornerRadius = new float[] { 0, 0, 0, 0 };
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
m_Show = false;
|
||||
m_Color = Color.clear;
|
||||
m_Color0 = Color.clear;
|
||||
m_ToColor = Color.clear;
|
||||
m_ToColor2 = Color.clear;
|
||||
m_BackgroundColor = Color.clear;
|
||||
m_BackgroundWidth = 0;
|
||||
m_CenterColor = Color.clear;
|
||||
m_CenterGap = 0;
|
||||
m_BorderWidth = 0;
|
||||
m_BorderGap = 0;
|
||||
m_BorderColor = Color.clear;
|
||||
m_BorderColor0 = Color.clear;
|
||||
m_BorderToColor = Color.clear;
|
||||
m_Opacity = 1;
|
||||
m_ItemFormatter = null;
|
||||
m_ItemMarker = null;
|
||||
m_NumericFormatter = "";
|
||||
if (m_CornerRadius == null)
|
||||
{
|
||||
m_CornerRadius = new float[] { 0, 0, 0, 0 };
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < m_CornerRadius.Length; i++)
|
||||
m_CornerRadius[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 数据项颜色。
|
||||
/// </summary>
|
||||
public Color32 color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 数据项颜色。
|
||||
/// </summary>
|
||||
public Color32 color0
|
||||
{
|
||||
get { return m_Color0; }
|
||||
set { if (PropertyUtil.SetColor(ref m_Color0, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gradient color1.
|
||||
/// |渐变色的颜色1。
|
||||
/// </summary>
|
||||
public Color32 toColor
|
||||
{
|
||||
get { return m_ToColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gradient color2.Only valid in line diagrams.
|
||||
/// |渐变色的颜色2。只在折线图中有效。
|
||||
/// </summary>
|
||||
public Color32 toColor2
|
||||
{
|
||||
get { return m_ToColor2; }
|
||||
set { if (PropertyUtil.SetColor(ref m_ToColor2, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 数据项背景颜色。
|
||||
/// </summary>
|
||||
public Color32 backgroundColor
|
||||
{
|
||||
get { return m_BackgroundColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 数据项背景宽度。
|
||||
/// </summary>
|
||||
public float backgroundWidth
|
||||
{
|
||||
get { return m_BackgroundWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BackgroundWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 中心区域颜色。
|
||||
/// </summary>
|
||||
public Color32 centerColor
|
||||
{
|
||||
get { return m_CenterColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_CenterColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 中心区域间隙。
|
||||
/// </summary>
|
||||
public float centerGap
|
||||
{
|
||||
get { return m_CenterGap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_CenterGap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 边框的颜色。
|
||||
/// </summary>
|
||||
public Color32 borderColor
|
||||
{
|
||||
get { return m_BorderColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BorderColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 边框的颜色。
|
||||
/// </summary>
|
||||
public Color32 borderColor0
|
||||
{
|
||||
get { return m_BorderColor0; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BorderColor0, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 边框的渐变色。
|
||||
/// </summary>
|
||||
public Color32 borderToColor
|
||||
{
|
||||
get { return m_BorderToColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BorderToColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 边框宽。
|
||||
/// </summary>
|
||||
public float borderWidth
|
||||
{
|
||||
get { return m_BorderWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 边框间隙。
|
||||
/// </summary>
|
||||
public float borderGap
|
||||
{
|
||||
get { return m_BorderGap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BorderGap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|
||||
/// </summary>
|
||||
public float opacity
|
||||
{
|
||||
get { return m_Opacity; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 提示框单项的字符串模版格式器。具体配置参考`Tooltip`的`formatter`
|
||||
/// </summary>
|
||||
public string itemFormatter
|
||||
{
|
||||
get { return m_ItemFormatter; }
|
||||
set { if (PropertyUtil.SetClass(ref m_ItemFormatter, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 提示框单项的字符标志。用在Tooltip中。
|
||||
/// </summary>
|
||||
public string itemMarker
|
||||
{
|
||||
get { return m_ItemMarker; }
|
||||
set { if (PropertyUtil.SetClass(ref m_ItemMarker, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Standard numeric format strings.
|
||||
/// |标准数字格式字符串。用于将数值格式化显示为字符串。
|
||||
/// 使用Axx的形式:A是格式说明符的单字符,支持C货币、D十进制、E指数、F定点数、G常规、N数字、P百分比、R往返、X十六进制的。xx是精度说明,从0-99。
|
||||
/// 参考:https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string numericFormatter
|
||||
{
|
||||
get { return m_NumericFormatter; }
|
||||
set { if (PropertyUtil.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <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)).
|
||||
/// |圆角半径。用数组分别指定4个圆角半径(顺时针左上,右上,右下,左下)。
|
||||
/// </summary>
|
||||
public float[] cornerRadius
|
||||
{
|
||||
get { return m_CornerRadius; }
|
||||
set { if (PropertyUtil.SetClass(ref m_CornerRadius, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 实际边框宽。边框不显示时为0。
|
||||
/// </summary>
|
||||
public float runtimeBorderWidth { get { return NeedShowBorder() ? borderWidth : 0; } }
|
||||
|
||||
/// <summary>
|
||||
/// 是否需要显示边框。
|
||||
/// </summary>
|
||||
public bool NeedShowBorder()
|
||||
{
|
||||
return borderWidth != 0 && !ChartHelper.IsClearColor(borderColor);
|
||||
}
|
||||
|
||||
public Color32 GetColor()
|
||||
{
|
||||
if (m_Opacity == 1 || m_Color.a == 0)
|
||||
return m_Color;
|
||||
|
||||
var color = m_Color;
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
public Color32 GetToColor()
|
||||
{
|
||||
if (m_Opacity == 1 || m_ToColor.a == 0)
|
||||
return m_ToColor;
|
||||
|
||||
var color = m_ToColor;
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
public Color32 GetColor0()
|
||||
{
|
||||
if (m_Opacity == 1 || m_Color0.a == 0)
|
||||
return m_Color0;
|
||||
|
||||
var color = m_Color0;
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
public Color32 GetColor(Color32 defaultColor)
|
||||
{
|
||||
var color = ChartHelper.IsClearColor(m_Color) ? defaultColor : m_Color;
|
||||
|
||||
if (m_Opacity == 1 || color.a == 0)
|
||||
return color;
|
||||
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
public Color32 GetColor0(Color32 defaultColor)
|
||||
{
|
||||
var color = ChartHelper.IsClearColor(m_Color0) ? defaultColor : m_Color0;
|
||||
|
||||
if (m_Opacity == 1 || color.a == 0)
|
||||
return color;
|
||||
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
public Color32 GetBorderColor(Color32 defaultColor)
|
||||
{
|
||||
var color = ChartHelper.IsClearColor(m_BorderColor) ? defaultColor : m_BorderColor;
|
||||
|
||||
if (m_Opacity == 1 || color.a == 0)
|
||||
return color;
|
||||
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
public Color32 GetBorderColor0(Color32 defaultColor)
|
||||
{
|
||||
var color = ChartHelper.IsClearColor(m_BorderColor0) ? defaultColor : m_BorderColor0;
|
||||
|
||||
if (m_Opacity == 1 || color.a == 0)
|
||||
return color;
|
||||
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
public bool IsNeedGradient()
|
||||
{
|
||||
return !ChartHelper.IsClearColor(m_ToColor) || !ChartHelper.IsClearColor(m_ToColor2);
|
||||
}
|
||||
|
||||
public Color32 GetGradientColor(float value, Color32 defaultColor)
|
||||
{
|
||||
if (!IsNeedGradient())
|
||||
return ChartConst.clearColor32;
|
||||
|
||||
value = Mathf.Clamp01(value);
|
||||
var startColor = ChartHelper.IsClearColor(m_Color) ? defaultColor : m_Color;
|
||||
Color32 color;
|
||||
|
||||
if (!ChartHelper.IsClearColor(m_ToColor2))
|
||||
{
|
||||
if (value <= 0.5f)
|
||||
color = Color32.Lerp(startColor, m_ToColor, 2 * value);
|
||||
else
|
||||
color = Color32.Lerp(m_ToColor, m_ToColor2, 2 * (value - 0.5f));
|
||||
}
|
||||
else
|
||||
{
|
||||
color = Color32.Lerp(startColor, m_ToColor, value);
|
||||
}
|
||||
if (m_Opacity != 1)
|
||||
{
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
public bool IsNeedCorner()
|
||||
{
|
||||
if (m_CornerRadius == null) return false;
|
||||
foreach (var value in m_CornerRadius)
|
||||
{
|
||||
if (value != 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ca9b30f9779c4a16b60cc21334828b0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[System.Serializable]
|
||||
public class Level : ChildComponent
|
||||
{
|
||||
[SerializeField] private LabelStyle m_Label = new LabelStyle();
|
||||
[SerializeField] private LabelStyle m_UpperLabel = new LabelStyle();
|
||||
[SerializeField] private ItemStyle m_ItemStyle = new ItemStyle();
|
||||
/// <summary>
|
||||
/// 文本标签样式。
|
||||
/// </summary>
|
||||
public LabelStyle label { get { return m_Label; } }
|
||||
/// <summary>
|
||||
/// 上方的文本标签样式。
|
||||
/// </summary>
|
||||
public LabelStyle upperLabel { get { return m_UpperLabel; } }
|
||||
/// <summary>
|
||||
/// 数据项样式。
|
||||
/// </summary>
|
||||
public ItemStyle itemStyle { get { return m_ItemStyle; } }
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class LevelStyle : ChildComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = false;
|
||||
[SerializeField] private List<Level> m_Levels = new List<Level>() { new Level() };
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用LevelStyle
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// 各层节点对应的配置。当enableLevels为true时生效,levels[0]对应的第一层的配置,levels[1]对应第二层,依次类推。当levels中没有对应层时用默认的设置。
|
||||
/// </summary>
|
||||
public List<Level> levels { get { return m_Levels; } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3760e89d324d7413d95a2ac1d434a546
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class LineArrow : ChildComponent, ISerieExtraComponent
|
||||
{
|
||||
public enum Position
|
||||
{
|
||||
/// <summary>
|
||||
/// 末端箭头
|
||||
/// </summary>
|
||||
End,
|
||||
/// <summary>
|
||||
/// 头端箭头
|
||||
/// </summary>
|
||||
Start
|
||||
}
|
||||
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private Position m_Position;
|
||||
[SerializeField]
|
||||
private ArrowStyle m_Arrow = new ArrowStyle()
|
||||
{
|
||||
width = 10,
|
||||
height = 15,
|
||||
offset = 0,
|
||||
dent = 3
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show the arrow.
|
||||
/// |是否显示箭头。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The position of arrow.
|
||||
/// |箭头位置。
|
||||
/// </summary>
|
||||
public Position position
|
||||
{
|
||||
get { return m_Position; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Position, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the arrow of line.
|
||||
/// |箭头。
|
||||
/// </summary>
|
||||
public ArrowStyle arrow
|
||||
{
|
||||
get { return m_Arrow; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Arrow, value)) SetVerticesDirty(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f2455acb3ba34409896bf03ddba593e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,238 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// The style of line.
|
||||
/// |线条样式。
|
||||
/// 注: 修改 lineStyle 中的颜色不会影响图例颜色,如果需要图例颜色和折线图颜色一致,需修改 itemStyle.color,线条颜色默认也会取该颜色。
|
||||
/// toColor,toColor2可设置水平方向的渐变,如需要设置垂直方向的渐变,可使用VisualMap。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class LineStyle : ChildComponent, ISerieDataComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// 线的类型。
|
||||
/// </summary>
|
||||
public enum Type
|
||||
{
|
||||
/// <summary>
|
||||
/// 实线
|
||||
/// </summary>
|
||||
Solid,
|
||||
/// <summary>
|
||||
/// 虚线
|
||||
/// </summary>
|
||||
Dashed,
|
||||
/// <summary>
|
||||
/// 点线
|
||||
/// </summary>
|
||||
Dotted,
|
||||
/// <summary>
|
||||
/// 点划线
|
||||
/// </summary>
|
||||
DashDot,
|
||||
/// <summary>
|
||||
/// 双点划线
|
||||
/// </summary>
|
||||
DashDotDot,
|
||||
None,
|
||||
}
|
||||
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private Type m_Type = Type.Solid;
|
||||
[SerializeField] private Color32 m_Color;
|
||||
[SerializeField] private Color32 m_ToColor;
|
||||
[SerializeField] private Color32 m_ToColor2;
|
||||
[SerializeField] private float m_Width = 0;
|
||||
[SerializeField] private float m_Length = 0;
|
||||
[SerializeField][Range(0, 1)] private float m_Opacity = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Whether show line.
|
||||
/// |是否显示线条。当作为子组件,它的父组件有参数控制是否显示时,改参数无效。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the type of line.
|
||||
/// |线的类型。
|
||||
/// </summary>
|
||||
public Type type
|
||||
{
|
||||
get { return m_Type; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of line, default use serie color.
|
||||
/// |线的颜色。
|
||||
/// </summary>
|
||||
public Color32 color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the middle color of line, default use serie color.
|
||||
/// |线的渐变颜色(需要水平方向渐变时)。
|
||||
/// </summary>
|
||||
public Color32 toColor
|
||||
{
|
||||
get { return m_ToColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the end color of line, default use serie color.
|
||||
/// |线的渐变颜色2(需要水平方向三个渐变色的渐变时)。
|
||||
/// </summary>
|
||||
public Color32 toColor2
|
||||
{
|
||||
get { return m_ToColor2; }
|
||||
set { if (PropertyUtil.SetColor(ref m_ToColor2, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the width of line.
|
||||
/// |线宽。
|
||||
/// </summary>
|
||||
public float width
|
||||
{
|
||||
get { return m_Width; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the length of line.
|
||||
/// |线长。
|
||||
/// </summary>
|
||||
public float length
|
||||
{
|
||||
get { return m_Length; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Length, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Opacity of the line. Supports value from 0 to 1, and the line will not be drawn when set to 0.
|
||||
/// |线的透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|
||||
/// </summary>
|
||||
public float opacity
|
||||
{
|
||||
get { return m_Opacity; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public LineStyle()
|
||||
{ }
|
||||
|
||||
public LineStyle(float width)
|
||||
{
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public LineStyle(LineStyle.Type type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public LineStyle(LineStyle.Type type, float width)
|
||||
{
|
||||
this.type = type;
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public LineStyle Clone()
|
||||
{
|
||||
var lineStyle = new LineStyle();
|
||||
lineStyle.show = show;
|
||||
lineStyle.type = type;
|
||||
lineStyle.color = color;
|
||||
lineStyle.toColor = toColor;
|
||||
lineStyle.toColor2 = toColor2;
|
||||
lineStyle.width = width;
|
||||
lineStyle.opacity = opacity;
|
||||
return lineStyle;
|
||||
}
|
||||
|
||||
public void Copy(LineStyle lineStyle)
|
||||
{
|
||||
show = lineStyle.show;
|
||||
type = lineStyle.type;
|
||||
color = lineStyle.color;
|
||||
toColor = lineStyle.toColor;
|
||||
toColor2 = lineStyle.toColor2;
|
||||
width = lineStyle.width;
|
||||
opacity = lineStyle.opacity;
|
||||
}
|
||||
|
||||
public Color32 GetColor()
|
||||
{
|
||||
if (m_Opacity == 1)
|
||||
return m_Color;
|
||||
|
||||
var color = m_Color;
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
public bool IsNeedGradient()
|
||||
{
|
||||
return !ChartHelper.IsClearColor(m_ToColor) || !ChartHelper.IsClearColor(m_ToColor2);
|
||||
}
|
||||
|
||||
public Color32 GetGradientColor(float value, Color32 defaultColor)
|
||||
{
|
||||
var color = ChartConst.clearColor32;
|
||||
if (!IsNeedGradient())
|
||||
return color;
|
||||
|
||||
value = Mathf.Clamp01(value);
|
||||
var startColor = ChartHelper.IsClearColor(m_Color) ? defaultColor : m_Color;
|
||||
|
||||
if (!ChartHelper.IsClearColor(m_ToColor2))
|
||||
{
|
||||
if (value <= 0.5f)
|
||||
color = Color32.Lerp(startColor, m_ToColor, 2 * value);
|
||||
else
|
||||
color = Color32.Lerp(m_ToColor, m_ToColor2, 2 * (value - 0.5f));
|
||||
}
|
||||
else
|
||||
{
|
||||
color = Color32.Lerp(startColor, m_ToColor, value);
|
||||
}
|
||||
if (m_Opacity != 1)
|
||||
{
|
||||
color.a = (byte) (color.a * m_Opacity);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
public Type GetType(Type themeType)
|
||||
{
|
||||
return type == Type.None ? themeType : type;
|
||||
}
|
||||
|
||||
public float GetWidth(float themeWidth)
|
||||
{
|
||||
return width == 0 ? themeWidth : width;
|
||||
}
|
||||
|
||||
public float GetLength(float themeLength)
|
||||
{
|
||||
return length == 0 ? themeLength : length;
|
||||
}
|
||||
|
||||
public Color32 GetColor(Color32 themeColor)
|
||||
{
|
||||
if (!ChartHelper.IsClearColor(color))
|
||||
{
|
||||
return GetColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
var color = themeColor;
|
||||
color.a = (byte) (color.a * opacity);
|
||||
return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 092f08a2daa4b4013a72ffc3c9a18f85
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,321 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
#if dUI_TextMeshPro
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// Location type. Quick to set the general location.
|
||||
/// |位置类型。通过Align快速设置大体位置,再通过left,right,top,bottom微调具体位置。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class Location : ChildComponent, IPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// 对齐方式
|
||||
/// </summary>
|
||||
public enum Align
|
||||
{
|
||||
TopLeft,
|
||||
TopRight,
|
||||
TopCenter,
|
||||
BottomLeft,
|
||||
BottomRight,
|
||||
BottomCenter,
|
||||
Center,
|
||||
CenterLeft,
|
||||
CenterRight
|
||||
}
|
||||
|
||||
[SerializeField] private Align m_Align = Align.TopCenter;
|
||||
[SerializeField] private float m_Left;
|
||||
[SerializeField] private float m_Right;
|
||||
[SerializeField] private float m_Top;
|
||||
[SerializeField] private float m_Bottom;
|
||||
|
||||
private TextAnchor m_TextAlignment;
|
||||
#if dUI_TextMeshPro
|
||||
private TextAlignmentOptions m_TMPTextAlignment;
|
||||
#endif
|
||||
private Vector2 m_AnchorMin;
|
||||
private Vector2 m_AnchorMax;
|
||||
private Vector2 m_Pivot;
|
||||
|
||||
/// <summary>
|
||||
/// 对齐方式。
|
||||
/// </summary>
|
||||
public Align align
|
||||
{
|
||||
get { return m_Align; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Align, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between component and the left side of the container.
|
||||
/// |离容器左侧的距离。
|
||||
/// </summary>
|
||||
public float left
|
||||
{
|
||||
get { return m_Left; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Left, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between component and the left side of the container.
|
||||
/// |离容器右侧的距离。
|
||||
/// </summary>
|
||||
public float right
|
||||
{
|
||||
get { return m_Right; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Right, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between component and the left side of the container.
|
||||
/// |离容器上侧的距离。
|
||||
/// </summary>
|
||||
public float top
|
||||
{
|
||||
get { return m_Top; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Top, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between component and the left side of the container.
|
||||
/// |离容器下侧的距离。
|
||||
/// </summary>
|
||||
public float bottom
|
||||
{
|
||||
get { return m_Bottom; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Bottom, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the anchor of text.
|
||||
/// |Location对应的Anchor锚点
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public TextAnchor runtimeTextAlignment { get { return m_TextAlignment; } }
|
||||
|
||||
#if dUI_TextMeshPro
|
||||
public TextAlignmentOptions runtimeTMPTextAlignment { get { return m_TMPTextAlignment; } }
|
||||
#endif
|
||||
/// <summary>
|
||||
/// the minimum achor.
|
||||
/// |Location对应的anchorMin。
|
||||
/// </summary>
|
||||
public Vector2 runtimeAnchorMin { get { return m_AnchorMin; } }
|
||||
/// <summary>
|
||||
/// the maximun achor.
|
||||
/// |Location对应的anchorMax.
|
||||
/// |</summary>
|
||||
public Vector2 runtimeAnchorMax { get { return m_AnchorMax; } }
|
||||
/// <summary>
|
||||
/// the povot.
|
||||
/// |Loation对应的中心点。
|
||||
/// </summary>
|
||||
public Vector2 runtimePivot { get { return m_Pivot; } }
|
||||
public float runtimeLeft { get; private set; }
|
||||
public float runtimeRight { get; private set; }
|
||||
public float runtimeBottom { get; private set; }
|
||||
public float runtimeTop { get; private set; }
|
||||
|
||||
public static Location defaultLeft
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Location()
|
||||
{
|
||||
align = Align.CenterLeft,
|
||||
left = 0.03f,
|
||||
right = 0,
|
||||
top = 0,
|
||||
bottom = 0
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static Location defaultRight
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Location()
|
||||
{
|
||||
align = Align.CenterRight,
|
||||
left = 0,
|
||||
right = 0.03f,
|
||||
top = 0,
|
||||
bottom = 0
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static Location defaultTop
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Location()
|
||||
{
|
||||
align = Align.TopCenter,
|
||||
left = 0,
|
||||
right = 0,
|
||||
top = 0.03f,
|
||||
bottom = 0
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static Location defaultBottom
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Location()
|
||||
{
|
||||
align = Align.BottomCenter,
|
||||
left = 0,
|
||||
right = 0,
|
||||
top = 0,
|
||||
bottom = 0.03f
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAlign()
|
||||
{
|
||||
switch (m_Align)
|
||||
{
|
||||
case Align.BottomCenter:
|
||||
m_TextAlignment = TextAnchor.LowerCenter;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.Bottom;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(0.5f, 0);
|
||||
m_AnchorMax = new Vector2(0.5f, 0);
|
||||
m_Pivot = new Vector2(0.5f, 0);
|
||||
break;
|
||||
case Align.BottomLeft:
|
||||
m_TextAlignment = TextAnchor.LowerLeft;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.BottomLeft;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(0, 0);
|
||||
m_AnchorMax = new Vector2(0, 0);
|
||||
m_Pivot = new Vector2(0, 0);
|
||||
break;
|
||||
case Align.BottomRight:
|
||||
m_TextAlignment = TextAnchor.LowerRight;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.BottomRight;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(1, 0);
|
||||
m_AnchorMax = new Vector2(1, 0);
|
||||
m_Pivot = new Vector2(1, 0);
|
||||
break;
|
||||
case Align.Center:
|
||||
m_TextAlignment = TextAnchor.MiddleCenter;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.Center;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(0.5f, 0.5f);
|
||||
m_AnchorMax = new Vector2(0.5f, 0.5f);
|
||||
m_Pivot = new Vector2(0.5f, 0.5f);
|
||||
break;
|
||||
case Align.CenterLeft:
|
||||
m_TextAlignment = TextAnchor.MiddleLeft;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.Left;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(0, 0.5f);
|
||||
m_AnchorMax = new Vector2(0, 0.5f);
|
||||
m_Pivot = new Vector2(0, 0.5f);
|
||||
break;
|
||||
case Align.CenterRight:
|
||||
m_TextAlignment = TextAnchor.MiddleRight;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.Right;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(1, 0.5f);
|
||||
m_AnchorMax = new Vector2(1, 0.5f);
|
||||
m_Pivot = new Vector2(1, 0.5f);
|
||||
break;
|
||||
case Align.TopCenter:
|
||||
m_TextAlignment = TextAnchor.UpperCenter;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.Top;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(0.5f, 1);
|
||||
m_AnchorMax = new Vector2(0.5f, 1);
|
||||
m_Pivot = new Vector2(0.5f, 1);
|
||||
break;
|
||||
case Align.TopLeft:
|
||||
m_TextAlignment = TextAnchor.UpperLeft;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.TopLeft;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(0, 1);
|
||||
m_AnchorMax = new Vector2(0, 1);
|
||||
m_Pivot = new Vector2(0, 1);
|
||||
break;
|
||||
case Align.TopRight:
|
||||
m_TextAlignment = TextAnchor.UpperRight;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.TopRight;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(1, 1);
|
||||
m_AnchorMax = new Vector2(1, 1);
|
||||
m_Pivot = new Vector2(1, 1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateRuntimeData(float chartWidth, float chartHeight)
|
||||
{
|
||||
runtimeLeft = left <= 1 ? left * chartWidth : left;
|
||||
runtimeRight = right <= 1 ? right * chartWidth : right;
|
||||
runtimeTop = top <= 1 ? top * chartHeight : top;
|
||||
runtimeBottom = bottom <= 1 ? bottom * chartHeight : bottom;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回在坐标系中的具体位置
|
||||
/// </summary>
|
||||
/// <param name="chartWidth"></param>
|
||||
/// <param name="chartHeight"></param>
|
||||
/// <returns></returns>
|
||||
public Vector3 GetPosition(float chartWidth, float chartHeight)
|
||||
{
|
||||
UpdateRuntimeData(chartWidth, chartHeight);
|
||||
switch (align)
|
||||
{
|
||||
case Align.BottomCenter:
|
||||
return new Vector3(chartWidth / 2, runtimeBottom);
|
||||
case Align.BottomLeft:
|
||||
return new Vector3(runtimeLeft, runtimeBottom);
|
||||
case Align.BottomRight:
|
||||
return new Vector3(chartWidth - runtimeRight, runtimeBottom);
|
||||
case Align.Center:
|
||||
return new Vector3(chartWidth / 2, chartHeight / 2);
|
||||
case Align.CenterLeft:
|
||||
return new Vector3(runtimeLeft, chartHeight / 2);
|
||||
case Align.CenterRight:
|
||||
return new Vector3(chartWidth - runtimeRight, chartHeight / 2);
|
||||
case Align.TopCenter:
|
||||
return new Vector3(chartWidth / 2, chartHeight - runtimeTop);
|
||||
case Align.TopLeft:
|
||||
return new Vector3(runtimeLeft, chartHeight - runtimeTop);
|
||||
case Align.TopRight:
|
||||
return new Vector3(chartWidth - runtimeRight, chartHeight - runtimeTop);
|
||||
default:
|
||||
return Vector2.zero;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 属性变更时更新textAnchor,minAnchor,maxAnchor,pivot
|
||||
/// </summary>
|
||||
public void OnChanged()
|
||||
{
|
||||
UpdateAlign();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7922ce86a6b0f4813a7f34e004b92e9a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,243 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// The way to get serie symbol size.
|
||||
/// |获取标记图形大小的方式。
|
||||
/// </summary>
|
||||
public enum SymbolSizeType
|
||||
{
|
||||
/// <summary>
|
||||
/// Specify constant for symbol size.
|
||||
/// |自定义大小。
|
||||
/// </summary>
|
||||
Custom,
|
||||
/// <summary>
|
||||
/// Specify the dataIndex and dataScale to calculate symbol size.
|
||||
/// |通过 dataIndex 从数据中获取,再乘以一个比例系数 dataScale 。
|
||||
/// </summary>
|
||||
FromData,
|
||||
/// <summary>
|
||||
/// Specify function for symbol size.
|
||||
/// |通过委托函数获取。
|
||||
/// </summary>
|
||||
Function,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 系列数据项的标记的图形
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class SerieSymbol : SymbolStyle, ISerieDataComponent
|
||||
{
|
||||
[SerializeField] private SymbolSizeType m_SizeType = SymbolSizeType.Custom;
|
||||
[SerializeField] private float m_SelectedSize = 0f;
|
||||
[SerializeField] private int m_DataIndex = 1;
|
||||
[SerializeField] private float m_DataScale = 1;
|
||||
[SerializeField] private float m_SelectedDataScale = 1.5f;
|
||||
[SerializeField] private SymbolSizeFunction m_SizeFunction;
|
||||
[SerializeField] private SymbolSizeFunction m_SelectedSizeFunction;
|
||||
[SerializeField] private int m_StartIndex;
|
||||
[SerializeField] private int m_Interval;
|
||||
[SerializeField] private bool m_ForceShowLast = false;
|
||||
[SerializeField] private bool m_Repeat = false;
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
m_SizeType = SymbolSizeType.Custom;
|
||||
m_SelectedSize = 0f;
|
||||
m_DataIndex = 1;
|
||||
m_DataScale = 1;
|
||||
m_SelectedDataScale = 1.5f;
|
||||
m_SizeFunction = null;
|
||||
m_SelectedSizeFunction = null;
|
||||
m_StartIndex = 0;
|
||||
m_Interval = 0;
|
||||
m_ForceShowLast = false;
|
||||
m_Repeat = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the type of symbol size.
|
||||
/// |标记图形的大小获取方式。
|
||||
/// </summary>
|
||||
public SymbolSizeType sizeType
|
||||
{
|
||||
get { return m_SizeType; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SizeType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the size of selected symbol.
|
||||
/// |被选中的标记的大小。
|
||||
/// </summary>
|
||||
public float selectedSize
|
||||
{
|
||||
get { return m_SelectedSize; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SelectedSize, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// whitch data index is when the sizeType assined as FromData.
|
||||
/// |当sizeType指定为FromData时,指定的数据源索引。
|
||||
/// </summary>
|
||||
public int dataIndex
|
||||
{
|
||||
get { return m_DataIndex; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_DataIndex, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the scale of data when sizeType assined as FromData.
|
||||
/// |当sizeType指定为FromData时,指定的倍数系数。
|
||||
/// </summary>
|
||||
public float dataScale
|
||||
{
|
||||
get { return m_DataScale; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_DataScale, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the scale of selected data when sizeType assined as FromData.
|
||||
/// |当sizeType指定为FromData时,指定的高亮倍数系数。
|
||||
/// </summary>
|
||||
public float selectedDataScale
|
||||
{
|
||||
get { return m_SelectedDataScale; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SelectedDataScale, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the function of size when sizeType assined as Function.
|
||||
/// |当sizeType指定为Function时,指定的委托函数。
|
||||
/// </summary>
|
||||
public SymbolSizeFunction sizeFunction
|
||||
{
|
||||
get { return m_SizeFunction; }
|
||||
set { if (PropertyUtil.SetClass(ref m_SizeFunction, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the function of size when sizeType assined as Function.
|
||||
/// |当sizeType指定为Function时,指定的高亮委托函数。
|
||||
/// </summary>
|
||||
public SymbolSizeFunction selectedSizeFunction
|
||||
{
|
||||
get { return m_SelectedSizeFunction; }
|
||||
set { if (PropertyUtil.SetClass(ref m_SelectedSizeFunction, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the index start to show symbol.
|
||||
/// |开始显示图形标记的索引。
|
||||
/// </summary>
|
||||
public int startIndex
|
||||
{
|
||||
get { return m_StartIndex; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_StartIndex, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the interval of show symbol.
|
||||
/// |显示图形标记的间隔。0表示显示所有标签,1表示隔一个隔显示一个标签,以此类推。
|
||||
/// </summary>
|
||||
public int interval
|
||||
{
|
||||
get { return m_Interval; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Interval, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// whether to show the last symbol.
|
||||
/// |是否强制显示最后一个图形标记。
|
||||
/// </summary>
|
||||
public bool forceShowLast
|
||||
{
|
||||
get { return m_ForceShowLast; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ForceShowLast, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 图形是否重复。
|
||||
/// </summary>
|
||||
public bool repeat
|
||||
{
|
||||
get { return m_Repeat; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Repeat, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据指定的sizeType获得标记的大小
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public float GetSize(List<double> data, float themeSize)
|
||||
{
|
||||
switch (m_SizeType)
|
||||
{
|
||||
case SymbolSizeType.Custom:
|
||||
return size == 0 ? themeSize : size;
|
||||
case SymbolSizeType.FromData:
|
||||
if (data != null && dataIndex >= 0 && dataIndex < data.Count)
|
||||
{
|
||||
return (float) data[dataIndex] * m_DataScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
return size == 0 ? themeSize : size;
|
||||
}
|
||||
case SymbolSizeType.Function:
|
||||
if (data != null && sizeFunction != null) return sizeFunction(data);
|
||||
else return size == 0 ? themeSize : size;
|
||||
default:
|
||||
return size == 0 ? themeSize : size;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据sizeType获得高亮时的标记大小
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public float GetSelectedSize(List<double> data, float themeSelectedSize)
|
||||
{
|
||||
switch (m_SizeType)
|
||||
{
|
||||
case SymbolSizeType.Custom:
|
||||
|
||||
return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||
|
||||
case SymbolSizeType.FromData:
|
||||
|
||||
if (data != null && dataIndex >= 0 && dataIndex < data.Count)
|
||||
{
|
||||
return (float) data[dataIndex] * m_SelectedDataScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||
}
|
||||
|
||||
case SymbolSizeType.Function:
|
||||
|
||||
if (data != null && selectedSizeFunction != null)
|
||||
return selectedSizeFunction(data);
|
||||
else
|
||||
return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||
|
||||
default:
|
||||
return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowSymbol(int dataIndex, int dataCount)
|
||||
{
|
||||
if (!show)
|
||||
return false;
|
||||
|
||||
if (dataIndex < startIndex)
|
||||
return false;
|
||||
|
||||
if (m_Interval <= 0)
|
||||
return true;
|
||||
|
||||
if (m_ForceShowLast && dataIndex == dataCount - 1)
|
||||
return true;
|
||||
|
||||
return (dataIndex - startIndex) % (m_Interval + 1) == 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd2852f4c46ae4dbd8c105e62dcce9a2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[System.Serializable]
|
||||
public class StageColor : ChildComponent
|
||||
{
|
||||
[SerializeField] private float m_Percent;
|
||||
[SerializeField] private Color32 m_Color;
|
||||
/// <summary>
|
||||
/// 结束位置百分比。
|
||||
/// </summary>
|
||||
public float percent { get { return m_Percent; } set { m_Percent = value; } }
|
||||
/// <summary>
|
||||
/// 颜色。
|
||||
/// </summary>
|
||||
public Color32 color { get { return m_Color; } set { m_Color = value; } }
|
||||
|
||||
public StageColor(float percent, Color32 color)
|
||||
{
|
||||
m_Percent = percent;
|
||||
m_Color = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d40f9dfbc90e744858784753e0d7109d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,191 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// the type of symbol.
|
||||
/// |标记图形的类型。
|
||||
/// </summary>
|
||||
public enum SymbolType
|
||||
{
|
||||
/// <summary>
|
||||
/// 不显示标记。
|
||||
/// </summary>
|
||||
None,
|
||||
/// <summary>
|
||||
/// 自定义标记。
|
||||
/// </summary>
|
||||
Custom,
|
||||
/// <summary>
|
||||
/// 圆形。
|
||||
/// </summary>
|
||||
Circle,
|
||||
/// <summary>
|
||||
/// 空心圆。
|
||||
/// </summary>
|
||||
EmptyCircle,
|
||||
/// <summary>
|
||||
/// 正方形。可通过设置`itemStyle`的`cornerRadius`变成圆角矩形。
|
||||
/// </summary>
|
||||
Rect,
|
||||
/// <summary>
|
||||
/// 空心正方形。
|
||||
/// </summary>
|
||||
EmptyRect,
|
||||
/// <summary>
|
||||
/// 三角形。
|
||||
/// </summary>
|
||||
Triangle,
|
||||
/// <summary>
|
||||
/// 空心三角形。
|
||||
/// </summary>
|
||||
EmptyTriangle,
|
||||
/// <summary>
|
||||
/// 菱形。
|
||||
/// </summary>
|
||||
Diamond,
|
||||
/// <summary>
|
||||
/// 空心菱形。
|
||||
/// </summary>
|
||||
EmptyDiamond,
|
||||
/// <summary>
|
||||
/// 箭头。
|
||||
/// </summary>
|
||||
Arrow,
|
||||
/// <summary>
|
||||
/// 空心箭头。
|
||||
/// </summary>
|
||||
EmptyArrow
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 系列数据项的标记的图形
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class SymbolStyle : ChildComponent
|
||||
{
|
||||
[SerializeField] protected bool m_Show = true;
|
||||
[SerializeField] protected SymbolType m_Type = SymbolType.EmptyCircle;
|
||||
[SerializeField] protected float m_Size = 0f;
|
||||
[SerializeField] protected float m_Gap = 0;
|
||||
[SerializeField] protected float m_Width = 0f;
|
||||
[SerializeField] protected float m_Height = 0f;
|
||||
[SerializeField] protected Vector2 m_Offset = Vector2.zero;
|
||||
[SerializeField] protected Sprite m_Image;
|
||||
[SerializeField] protected Image.Type m_ImageType;
|
||||
[SerializeField] protected Color32 m_Color;
|
||||
|
||||
public virtual void Reset()
|
||||
{
|
||||
m_Show = false;
|
||||
m_Type = SymbolType.EmptyCircle;
|
||||
m_Size = 0f;
|
||||
m_Gap = 0;
|
||||
m_Width = 0f;
|
||||
m_Height = 0f;
|
||||
m_Offset = Vector2.zero;
|
||||
m_Image = null;
|
||||
m_ImageType = Image.Type.Simple;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the symbol is showed.
|
||||
/// |是否显示标记。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the type of symbol.
|
||||
/// |标记类型。
|
||||
/// </summary>
|
||||
public SymbolType type
|
||||
{
|
||||
get { return m_Type; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the size of symbol.
|
||||
/// |标记的大小。
|
||||
/// </summary>
|
||||
public float size
|
||||
{
|
||||
get { return m_Size; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Size, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the gap of symbol and line segment.
|
||||
/// |图形标记和线条的间隙距离。
|
||||
/// </summary>
|
||||
public float gap
|
||||
{
|
||||
get { return m_Gap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 图形的宽。
|
||||
/// </summary>
|
||||
public float width
|
||||
{
|
||||
get { return m_Width; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 图形的高。
|
||||
/// </summary>
|
||||
public float height
|
||||
{
|
||||
get { return m_Height; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Height, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 自定义的标记图形。
|
||||
/// </summary>
|
||||
public Sprite image
|
||||
{
|
||||
get { return m_Image; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Image, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the fill type of image.
|
||||
/// |图形填充类型。
|
||||
/// </summary>
|
||||
public Image.Type imageType
|
||||
{
|
||||
get { return m_ImageType; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ImageType, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 图形的偏移。
|
||||
/// </summary>
|
||||
public Vector2 offset
|
||||
{
|
||||
get { return m_Offset; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 图形的颜色。
|
||||
/// </summary>
|
||||
public Color32 color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Color, value)) SetAllDirty(); }
|
||||
}
|
||||
public Vector3 offset3 { get { return new Vector3(m_Offset.x, m_Offset.y, 0); } }
|
||||
private List<float> m_AnimationSize = new List<float>() { 0, 5, 10 };
|
||||
/// <summary>
|
||||
/// the setting for effect scatter.
|
||||
/// |带有涟漪特效动画的散点图的动画参数。
|
||||
/// </summary>
|
||||
public List<float> animationSize { get { return m_AnimationSize; } }
|
||||
|
||||
public Color32 GetColor(Color32 defaultColor)
|
||||
{
|
||||
return ChartHelper.IsClearColor(m_Color) ? defaultColor : m_Color;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 837d37f4d6f614b38bef9f075a64b6dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,150 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// Text character limitation and adaptation component. When the length of the text exceeds the set length,
|
||||
/// it is cropped and suffixes are appended to the end.Only valid in the category axis.
|
||||
/// |文本字符限制和自适应。当文本长度超过设定的长度时进行裁剪,并将后缀附加在最后。
|
||||
/// 只在类目轴中有效。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TextLimit : ChildComponent
|
||||
{
|
||||
[SerializeField] private bool m_Enable = false;
|
||||
[SerializeField] private float m_MaxWidth = 0;
|
||||
[SerializeField] private float m_Gap = 1;
|
||||
[SerializeField] private string m_Suffix = "...";
|
||||
|
||||
/// <summary>
|
||||
/// Whether to enable text limit.
|
||||
/// |是否启用文本自适应。
|
||||
/// [default:true]
|
||||
/// </summary>
|
||||
public bool enable
|
||||
{
|
||||
get { return m_Enable; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Enable, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Set the maximum width. A default of 0 indicates automatic fetch; otherwise, custom.
|
||||
/// |Clipping occurs when the width of the text is greater than this value.
|
||||
/// |设定最大宽度。默认为0表示自动获取,否则表示自定义。当文本的宽度大于该值进行裁剪。
|
||||
/// </summary>
|
||||
public float maxWidth
|
||||
{
|
||||
get { return m_MaxWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MaxWidth, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// White pixel distance at both ends.
|
||||
/// |两边留白像素距离。
|
||||
/// [default:10f]
|
||||
/// </summary>
|
||||
public float gap
|
||||
{
|
||||
get { return m_Gap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Suffixes when the length exceeds.
|
||||
/// |长度超出时的后缀。
|
||||
/// [default: "..."]
|
||||
/// </summary>
|
||||
public string suffix
|
||||
{
|
||||
get { return m_Suffix; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Suffix, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
private ChartText m_RelatedText;
|
||||
private float m_RelatedTextWidth = 0;
|
||||
|
||||
public TextLimit Clone()
|
||||
{
|
||||
var textLimit = new TextLimit();
|
||||
textLimit.enable = enable;
|
||||
textLimit.maxWidth = maxWidth;
|
||||
textLimit.gap = gap;
|
||||
textLimit.suffix = suffix;
|
||||
return textLimit;
|
||||
}
|
||||
|
||||
public void Copy(TextLimit textLimit)
|
||||
{
|
||||
enable = textLimit.enable;
|
||||
maxWidth = textLimit.maxWidth;
|
||||
gap = textLimit.gap;
|
||||
suffix = textLimit.suffix;
|
||||
}
|
||||
|
||||
public void SetRelatedText(ChartText txt, float labelWidth)
|
||||
{
|
||||
m_RelatedText = txt;
|
||||
m_RelatedTextWidth = labelWidth;
|
||||
}
|
||||
|
||||
public string GetLimitContent(string content)
|
||||
{
|
||||
float checkWidth = m_MaxWidth > 0 ? m_MaxWidth : m_RelatedTextWidth;
|
||||
if (m_RelatedText == null || checkWidth <= 0)
|
||||
{
|
||||
return content;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Enable)
|
||||
{
|
||||
float len = m_RelatedText.GetPreferredWidth(content);
|
||||
float suffixLen = m_RelatedText.GetPreferredWidth(suffix);
|
||||
if (len >= checkWidth - m_Gap * 2)
|
||||
{
|
||||
return content.Substring(0, GetAdaptLength(content, suffixLen)) + suffix;
|
||||
}
|
||||
else
|
||||
{
|
||||
return content;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return content;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int GetAdaptLength(string content, float suffixLen)
|
||||
{
|
||||
int start = 0;
|
||||
int middle = content.Length / 2;
|
||||
int end = content.Length;
|
||||
float checkWidth = m_MaxWidth > 0 ? m_MaxWidth : m_RelatedTextWidth;
|
||||
|
||||
float limit = checkWidth - m_Gap * 2 - suffixLen;
|
||||
if (limit < 0)
|
||||
return 0;
|
||||
|
||||
float len = 0;
|
||||
while (len != limit && middle != start)
|
||||
{
|
||||
len = m_RelatedText.GetPreferredWidth(content.Substring(0, middle));
|
||||
if (len < limit)
|
||||
{
|
||||
start = middle;
|
||||
}
|
||||
else if (len > limit)
|
||||
{
|
||||
end = middle;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
middle = (start + end) / 2;
|
||||
}
|
||||
return middle;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f49509a5de044535b1dd3f192f7008c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// Settings related to text.
|
||||
/// |文本的内边距设置。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TextPadding : ChildComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private float m_Top = 2;
|
||||
[SerializeField] private float m_Right = 4;
|
||||
[SerializeField] private float m_Left = 4;
|
||||
[SerializeField] private float m_Bottom = 2;
|
||||
|
||||
public TextPadding() { }
|
||||
|
||||
public TextPadding(float top, float right, float bottom, float left)
|
||||
{
|
||||
SetPadding(top, right, bottom, left);
|
||||
}
|
||||
|
||||
public void SetPadding(float top, float right, float bottom, float left)
|
||||
{
|
||||
m_Top = top;;
|
||||
m_Right = right;
|
||||
m_Bottom = bottom;
|
||||
m_Left = left;
|
||||
}
|
||||
/// <summary>
|
||||
/// show padding.
|
||||
/// 是否显示。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// padding of top.
|
||||
/// |顶部间距。
|
||||
/// </summary>
|
||||
public float top
|
||||
{
|
||||
get { return m_Top; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Top, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// padding of right.
|
||||
/// |右部间距。
|
||||
/// </summary>
|
||||
public float right
|
||||
{
|
||||
get { return m_Right; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Right, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// padding of bottom.
|
||||
/// |底部间距。
|
||||
/// </summary>
|
||||
public float bottom
|
||||
{
|
||||
get { return m_Bottom; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Bottom, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// padding of left.
|
||||
/// |左边间距。
|
||||
/// </summary>
|
||||
public float left
|
||||
{
|
||||
get { return m_Left; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Left, value)) SetComponentDirty(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 407bba126a0854199a4686b44cc9407e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,234 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
#if dUI_TextMeshPro
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// Settings related to text.
|
||||
/// |文本的相关设置。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TextStyle : ChildComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private Font m_Font;
|
||||
[SerializeField] private bool m_AutoWrap = false;
|
||||
[SerializeField] private bool m_AutoAlign = true;
|
||||
[SerializeField] private float m_Rotate = 0;
|
||||
[SerializeField] private bool m_AutoColor = false;
|
||||
[SerializeField] private Color m_Color = Color.clear;
|
||||
[SerializeField] private int m_FontSize = 0;
|
||||
[SerializeField] private FontStyle m_FontStyle = FontStyle.Normal;
|
||||
[SerializeField] private float m_LineSpacing = 1f;
|
||||
[SerializeField] private TextAnchor m_Alignment = TextAnchor.MiddleCenter;
|
||||
#if dUI_TextMeshPro
|
||||
[SerializeField] private TMP_FontAsset m_TMPFont;
|
||||
[SerializeField] private FontStyles m_TMPFontStyle = FontStyles.Normal;
|
||||
[SerializeField] private TextAlignmentOptions m_TMPAlignment = TextAlignmentOptions.Left;
|
||||
#endif
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Rotation of text.
|
||||
/// |文本的旋转。
|
||||
/// [default: `0f`]
|
||||
/// </summary>
|
||||
public float rotate
|
||||
{
|
||||
get { return m_Rotate; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否开启自动颜色。当开启时,会自动设置颜色。
|
||||
/// </summary>
|
||||
public bool autoColor
|
||||
{
|
||||
get { return m_AutoColor; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_AutoColor, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of text.
|
||||
/// |文本的颜色。
|
||||
/// [default: `Color.clear`]
|
||||
/// </summary>
|
||||
public Color color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the font of text. When `null`, the theme's font is used by default.
|
||||
/// |文本字体。
|
||||
/// [default: null]
|
||||
/// </summary>
|
||||
public Font font
|
||||
{
|
||||
get { return m_Font; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Font, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// font size.
|
||||
/// |文本字体大小。
|
||||
/// [default: 18]
|
||||
/// </summary>
|
||||
public int fontSize
|
||||
{
|
||||
get { return m_FontSize; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// font style.
|
||||
/// |文本字体的风格。
|
||||
/// [default: FontStyle.Normal]
|
||||
/// </summary>
|
||||
public FontStyle fontStyle
|
||||
{
|
||||
get { return m_FontStyle; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_FontStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// text line spacing.
|
||||
/// |行间距。
|
||||
/// [default: 1f]
|
||||
/// </summary>
|
||||
public float lineSpacing
|
||||
{
|
||||
get { return m_LineSpacing; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineSpacing, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否自动换行。
|
||||
/// </summary>
|
||||
public bool autoWrap
|
||||
{
|
||||
get { return m_AutoWrap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_AutoWrap, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 文本是否让系统自动选对齐方式。为false时才会用alignment。
|
||||
/// </summary>
|
||||
public bool autoAlign
|
||||
{
|
||||
get { return m_AutoAlign; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_AutoAlign, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 对齐方式。
|
||||
/// </summary>
|
||||
public TextAnchor alignment
|
||||
{
|
||||
get { return m_Alignment; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Alignment, value)) SetComponentDirty(); }
|
||||
}
|
||||
#if dUI_TextMeshPro
|
||||
/// <summary>
|
||||
/// the font of textmeshpro.
|
||||
/// |TextMeshPro字体。
|
||||
/// </summary>
|
||||
public TMP_FontAsset tmpFont
|
||||
{
|
||||
get { return m_TMPFont; }
|
||||
set { if (PropertyUtil.SetClass(ref m_TMPFont, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the font style of TextMeshPro.
|
||||
/// |TextMeshPro字体类型。
|
||||
/// </summary>
|
||||
public FontStyles tmpFontStyle
|
||||
{
|
||||
get { return m_TMPFontStyle; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_TMPFontStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the text alignment of TextMeshPro.
|
||||
/// |TextMeshPro字体对齐方式。
|
||||
/// </summary>
|
||||
public TextAlignmentOptions tmpFontStyle
|
||||
{
|
||||
get { return m_TMPAlignment; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_TMPAlignment, value)) SetComponentDirty(); }
|
||||
}
|
||||
#endif
|
||||
|
||||
public TextStyle() { }
|
||||
|
||||
public TextStyle(int fontSize)
|
||||
{
|
||||
this.fontSize = fontSize;
|
||||
}
|
||||
|
||||
public TextStyle(int fontSize, FontStyle fontStyle)
|
||||
{
|
||||
this.fontSize = fontSize;
|
||||
this.fontStyle = fontStyle;
|
||||
}
|
||||
|
||||
public TextStyle(int fontSize, FontStyle fontStyle, Color color)
|
||||
{
|
||||
this.fontSize = fontSize;
|
||||
this.fontStyle = fontStyle;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public TextStyle(int fontSize, FontStyle fontStyle, Color color, int rorate)
|
||||
{
|
||||
this.fontSize = fontSize;
|
||||
this.fontStyle = fontStyle;
|
||||
this.color = color;
|
||||
this.rotate = rotate;
|
||||
}
|
||||
|
||||
public void Copy(TextStyle textStyle)
|
||||
{
|
||||
font = textStyle.font;
|
||||
rotate = textStyle.rotate;
|
||||
color = textStyle.color;
|
||||
fontSize = textStyle.fontSize;
|
||||
fontStyle = textStyle.fontStyle;
|
||||
lineSpacing = textStyle.lineSpacing;
|
||||
alignment = textStyle.alignment;
|
||||
autoWrap = textStyle.autoWrap;
|
||||
autoAlign = textStyle.autoAlign;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPFont = textStyle.tmpFont;
|
||||
m_TMPFontStyle = textStyle.tmpFontStyle;
|
||||
#endif
|
||||
}
|
||||
|
||||
public void UpdateAlignmentByLocation(Location location)
|
||||
{
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPAlignment = location.runtimeTMPTextAlignment;
|
||||
#else
|
||||
m_Alignment = location.runtimeTextAlignment;
|
||||
#endif
|
||||
}
|
||||
|
||||
public Color GetColor(Color defaultColor)
|
||||
{
|
||||
if (ChartHelper.IsClearColor(color))
|
||||
return defaultColor;
|
||||
else
|
||||
return color;
|
||||
}
|
||||
|
||||
public int GetFontSize(ComponentTheme defaultTheme)
|
||||
{
|
||||
if (fontSize == 0)
|
||||
return defaultTheme.fontSize;
|
||||
else
|
||||
return fontSize;
|
||||
}
|
||||
|
||||
public TextAnchor GetAlignment(TextAnchor defaultAlignment)
|
||||
{
|
||||
return m_AutoAlign ? defaultAlignment : alignment;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8f6b652968894ab195666501dda672c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user