2019-11-05 18:58:32 +08:00
|
|
|
/******************************************/
|
|
|
|
|
/* */
|
|
|
|
|
/* Copyright (c) 2018 monitor1394 */
|
|
|
|
|
/* https://github.com/monitor1394 */
|
|
|
|
|
/* */
|
|
|
|
|
/******************************************/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace XCharts
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Settings related to text.
|
|
|
|
|
/// 文本的相关设置。
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable]
|
2020-03-08 10:47:48 +08:00
|
|
|
public class TextStyle : SubComponent
|
2019-11-05 18:58:32 +08:00
|
|
|
{
|
2020-02-26 22:52:57 +08:00
|
|
|
[SerializeField] private Font m_Font;
|
2019-11-05 18:58:32 +08:00
|
|
|
[SerializeField] private float m_Rotate = 0;
|
|
|
|
|
[SerializeField] private Vector2 m_Offset = Vector2.zero;
|
|
|
|
|
[SerializeField] private Color m_Color = Color.clear;
|
2020-02-26 22:52:57 +08:00
|
|
|
[SerializeField] private Color m_BackgroundColor = Color.clear;
|
2019-11-05 18:58:32 +08:00
|
|
|
[SerializeField] private int m_FontSize = 18;
|
|
|
|
|
[SerializeField] private FontStyle m_FontStyle = FontStyle.Normal;
|
2020-02-26 22:52:57 +08:00
|
|
|
[SerializeField] private float m_LineSpacing = 1f;
|
2020-03-22 08:45:05 +08:00
|
|
|
// [SerializeField] private float m_PaddingLeft = 0f;
|
|
|
|
|
// [SerializeField] private float m_PaddingRight = 0f;
|
|
|
|
|
// [SerializeField] private float m_PaddingTop = 0f;
|
|
|
|
|
// [SerializeField] private float m_PaddingBottom = 0f;
|
2019-11-05 18:58:32 +08:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Rotation of text.
|
|
|
|
|
/// 文本的旋转。
|
|
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
public float rotate
|
|
|
|
|
{
|
|
|
|
|
get { return m_Rotate; }
|
|
|
|
|
set { if (PropertyUtility.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
|
|
|
|
|
}
|
2019-11-05 18:58:32 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// the offset of position.
|
|
|
|
|
/// 坐标偏移。
|
|
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
public Vector2 offset
|
|
|
|
|
{
|
|
|
|
|
get { return m_Offset; }
|
|
|
|
|
set { if (PropertyUtility.SetStruct(ref m_Offset, value)) SetComponentDirty(); }
|
|
|
|
|
}
|
2019-11-05 18:58:32 +08:00
|
|
|
|
2019-12-15 21:36:59 +08:00
|
|
|
public Vector3 offsetv3 { get { return new Vector3(m_Offset.x, m_Offset.y, 0); } }
|
|
|
|
|
|
2019-11-05 18:58:32 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// the color of text.
|
|
|
|
|
/// 文本的颜色。
|
|
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
public Color color
|
|
|
|
|
{
|
|
|
|
|
get { return m_Color; }
|
|
|
|
|
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetComponentDirty(); }
|
|
|
|
|
}
|
2019-11-05 18:58:32 +08:00
|
|
|
/// <summary>
|
2020-02-26 22:52:57 +08:00
|
|
|
/// the color of text.
|
|
|
|
|
/// 文本的背景颜色。
|
|
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
public Color backgroundColor
|
|
|
|
|
{
|
|
|
|
|
get { return m_BackgroundColor; }
|
|
|
|
|
set { if (PropertyUtility.SetColor(ref m_BackgroundColor, value)) SetComponentDirty(); }
|
|
|
|
|
}
|
2020-02-26 22:52:57 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// the font of text.
|
|
|
|
|
/// 文本字体
|
|
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
public Font font
|
|
|
|
|
{
|
|
|
|
|
get { return m_Font; }
|
|
|
|
|
set { if (PropertyUtility.SetClass(ref m_Font, value)) SetComponentDirty(); }
|
|
|
|
|
}
|
2020-02-26 22:52:57 +08:00
|
|
|
/// <summary>
|
2019-11-05 18:58:32 +08:00
|
|
|
/// font size.
|
|
|
|
|
/// 文本字体大小。
|
|
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
public int fontSize
|
|
|
|
|
{
|
|
|
|
|
get { return m_FontSize; }
|
|
|
|
|
set { if (PropertyUtility.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
|
|
|
|
|
}
|
2019-11-05 18:58:32 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// font style.
|
|
|
|
|
/// 文本字体的风格。
|
|
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
public FontStyle fontStyle
|
|
|
|
|
{
|
|
|
|
|
get { return m_FontStyle; }
|
|
|
|
|
set { if (PropertyUtility.SetStruct(ref m_FontStyle, value)) SetComponentDirty(); }
|
|
|
|
|
}
|
2020-02-13 09:23:30 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// text line spacing.
|
|
|
|
|
/// 行间距。
|
|
|
|
|
/// </summary>
|
2020-03-05 20:25:19 +08:00
|
|
|
public float lineSpacing
|
|
|
|
|
{
|
|
|
|
|
get { return m_LineSpacing; }
|
|
|
|
|
set { if (PropertyUtility.SetStruct(ref m_LineSpacing, value)) SetComponentDirty(); }
|
|
|
|
|
}
|
2019-11-05 18:58:32 +08:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|