3.0 - unitypackage

This commit is contained in:
monitor1394
2022-01-05 21:40:48 +08:00
parent c160867765
commit 228a4b2840
846 changed files with 105 additions and 467693 deletions

View File

@@ -0,0 +1,81 @@

using System;
using UnityEngine;
using UnityEngine.UI;
namespace XCharts
{
/// <summary>
/// Background component.
///
/// 背景组件。
/// </summary>
[Serializable]
[DisallowMultipleComponent]
[ComponentHandler(typeof(BackgroundHandler), false)]
public class Background : MainComponent
{
[SerializeField] private bool m_Show = true;
[SerializeField] private Sprite m_Image;
[SerializeField] private Image.Type m_ImageType;
[SerializeField] private Color m_ImageColor = Color.white;
[SerializeField] private bool m_HideThemeBackgroundColor = true;
/// <summary>
/// Whether to enable the background component.
/// 是否启用背景组件。
/// </summary>
public bool show
{
get { return m_Show; }
internal set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
}
/// <summary>
/// the image of background.
/// 背景图。
/// </summary>
public Sprite image
{
get { return m_Image; }
set { if (PropertyUtil.SetClass(ref m_Image, value)) SetComponentDirty(); }
}
/// <summary>
/// the fill type of background image.
/// 背景图填充类型。
/// </summary>
public Image.Type imageType
{
get { return m_ImageType; }
set { if (PropertyUtil.SetStruct(ref m_ImageType, value)) SetComponentDirty(); }
}
/// <summary>
/// 背景图颜色。
/// </summary>
public Color imageColor
{
get { return m_ImageColor; }
set { if (PropertyUtil.SetColor(ref m_ImageColor, value)) SetComponentDirty(); }
}
/// <summary>
/// Whether to hide the background color set in the theme when the background component is on.
/// 当background组件开启时是否隐藏主题中设置的背景色。
/// </summary>
public bool hideThemeBackgroundColor
{
get { return m_HideThemeBackgroundColor; }
set { if (PropertyUtil.SetStruct(ref m_HideThemeBackgroundColor, value)) SetVerticesDirty(); }
}
public override void SetDefaultValue()
{
m_Show = false;
m_Image = null;
m_ImageType = Image.Type.Sliced;
m_ImageColor = Color.white;
m_HideThemeBackgroundColor = true;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 524f7df5241cc4379ae241a73d5b2ff2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,76 @@
using System;
using UnityEngine;
using UnityEngine.UI;
using XUGL;
namespace XCharts
{
[UnityEngine.Scripting.Preserve]
internal sealed class BackgroundHandler : MainComponentHandler<Background>
{
private readonly string s_BackgroundObjectName = "background";
public override void InitComponent()
{
component.painter = chart.painter;
component.refreshComponent = delegate ()
{
var backgroundObj = ChartHelper.AddObject(s_BackgroundObjectName, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
component.gameObject = backgroundObj;
backgroundObj.hideFlags = chart.chartHideFlags;
var backgroundImage = ChartHelper.GetOrAddComponent<Image>(backgroundObj);
ChartHelper.UpdateRectTransform(backgroundObj, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
backgroundImage.sprite = component.image;
backgroundImage.type = component.imageType;
backgroundImage.color = component.imageColor;
backgroundObj.transform.SetSiblingIndex(0);
backgroundObj.SetActive(component.show);
};
component.refreshComponent();
}
//protected void DrawBackground(VertexHelper vh)
//{
//TODO: CooridateChart
// if (SeriesHelper.IsAnyClipSerie(m_Series))
// {
// var xLineDiff = xAxis0.axisLine.GetWidth(m_Theme.axis.lineWidth);
// var yLineDiff = yAxis0.axisLine.GetWidth(m_Theme.axis.lineWidth);
// var xSplitDiff = xAxis0.splitLine.GetWidth(m_Theme.axis.splitLineWidth);
// var ySplitDiff = yAxis0.splitLine.GetWidth(m_Theme.axis.splitLineWidth);
// foreach (var grid in m_Grids)
// {
// var cpty = grid.context.runtimeY + grid.context.runtimeHeight + ySplitDiff;
// var cp1 = new Vector3(grid.context.runtimeX - yLineDiff, grid.context.runtimeY - xLineDiff);
// var cp2 = new Vector3(grid.context.runtimeX - yLineDiff, cpty);
// var cp3 = new Vector3(grid.context.runtimeX + grid.context.runtimeWidth + xSplitDiff, cpty);
// var cp4 = new Vector3(grid.context.runtimeX + grid.context.runtimeWidth + xSplitDiff, grid.context.runtimeY - xLineDiff);
// var backgroundColor = ThemeHelper.GetBackgroundColor(m_Theme, m_Background);
// UGL.DrawQuadrilateral(vh, cp1, cp2, cp3, cp4, backgroundColor);
// }
// }
// else
// {
// base.DrawBackground(vh);
// }
// }
public override void DrawBase(VertexHelper vh)
{
if (!component.show)
return;
var p1 = new Vector3(chart.chartX, chart.chartY + chart.chartHeight);
var p2 = new Vector3(chart.chartX + chart.chartWidth, chart.chartY + chart.chartHeight);
var p3 = new Vector3(chart.chartX + chart.chartWidth, chart.chartY);
var p4 = new Vector3(chart.chartX, chart.chartY);
var backgroundColor = chart.theme.GetBackgroundColor(component);
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, backgroundColor);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f1cb3d1a2aa224bbe84eef2681cf3df4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: