mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 01:10:08 +00:00
3.0 - inspector
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XCharts.Runtime;
|
||||
using XUGL;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
namespace XCharts
|
||||
{
|
||||
public abstract class AxisHandler<T> : MainComponentHandler
|
||||
where T : Axis
|
||||
|
||||
@@ -3,16 +3,17 @@ using UnityEngine;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[Serializable]
|
||||
public class DebugInfo
|
||||
{
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private bool m_ShowDebugInfo = false;
|
||||
[SerializeField] protected bool m_ShowAllChildObject = false;
|
||||
[SerializeField] protected bool m_FoldSeries = false;
|
||||
[SerializeField]
|
||||
private TextStyle m_TextStyle = new TextStyle()
|
||||
private TextStyle m_DebugInfoTextStyle = new TextStyle()
|
||||
{
|
||||
fontSize = 18,
|
||||
backgroundColor = new Color32(32, 32, 32, 170),
|
||||
@@ -31,7 +32,8 @@ namespace XCharts.Runtime
|
||||
private ChartLabel m_Label;
|
||||
private List<float> m_FpsList = new List<float>();
|
||||
|
||||
|
||||
public bool showAllChildObject { get { return m_ShowAllChildObject; } }
|
||||
public bool foldSeries { get { return m_FoldSeries; } set { m_FoldSeries = value; } }
|
||||
public float fps { get; private set; }
|
||||
public float avgFps { get; private set; }
|
||||
public int refreshCount { get; internal set; }
|
||||
@@ -40,15 +42,15 @@ namespace XCharts.Runtime
|
||||
public void Init(BaseChart chart)
|
||||
{
|
||||
m_Chart = chart;
|
||||
m_Label = AddDebugInfoObject("debug", chart.transform, m_TextStyle, chart.theme);
|
||||
m_Label = AddDebugInfoObject("debug", chart.transform, m_DebugInfoTextStyle, chart.theme);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (clickChartCount >= 2)
|
||||
{
|
||||
m_Show = !m_Show;
|
||||
ChartHelper.SetActive(m_Label.transform, m_Show);
|
||||
m_ShowDebugInfo = !m_ShowDebugInfo;
|
||||
ChartHelper.SetActive(m_Label.transform, m_ShowDebugInfo);
|
||||
clickChartCount = 0;
|
||||
m_LastCheckShowTime = Time.realtimeSinceStartup;
|
||||
return;
|
||||
@@ -58,7 +60,7 @@ namespace XCharts.Runtime
|
||||
m_LastCheckShowTime = Time.realtimeSinceStartup;
|
||||
clickChartCount = 0;
|
||||
}
|
||||
if (!m_Show || m_Label == null)
|
||||
if (!m_ShowDebugInfo || m_Label == null)
|
||||
return;
|
||||
|
||||
m_FrameCount++;
|
||||
@@ -130,7 +132,7 @@ namespace XCharts.Runtime
|
||||
var labelGameObject = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
|
||||
labelGameObject.transform.SetAsLastSibling();
|
||||
labelGameObject.hideFlags = m_Chart.chartHideFlags;
|
||||
ChartHelper.SetActive(labelGameObject, m_Show);
|
||||
ChartHelper.SetActive(labelGameObject, m_ShowDebugInfo);
|
||||
|
||||
var label = ChartHelper.GetOrAddComponent<ChartLabel>(labelGameObject);
|
||||
label.labelBackground = label;
|
||||
|
||||
@@ -9,8 +9,9 @@ namespace XCharts.Runtime
|
||||
/// 全局参数设置组件。一般情况下可使用默认值,当有需要时可进行调整。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class Settings : ChildComponent
|
||||
public class Settings : MainComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] [Range(1, 20)] protected int m_MaxPainter = 10;
|
||||
[SerializeField] protected bool m_ReversePainter = false;
|
||||
[SerializeField] protected Material m_BasePainterMaterial;
|
||||
@@ -23,6 +24,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField] protected float m_LegendIconLineWidth = 2;
|
||||
[SerializeField] private float[] m_LegendIconCornerRadius = new float[] { 0.25f, 0.25f, 0.25f, 0.25f };
|
||||
|
||||
public bool show { get { return m_Show; } }
|
||||
/// <summary>
|
||||
/// max painter.
|
||||
/// 设定的painter数量。
|
||||
@@ -142,7 +144,7 @@ namespace XCharts.Runtime
|
||||
ChartHelper.CopyArray(m_LegendIconCornerRadius, settings.legendIconCornerRadius);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
public override void Reset()
|
||||
{
|
||||
Copy(DefaultSettings);
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb8cbed03560e47d59d15c19bc6cd11f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,198 +0,0 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// Vessel component for liquid chart. There can be multiple vessels in a Chart, which can be matched by vesselIndex in Serie.
|
||||
/// <para>
|
||||
/// 容器组件。
|
||||
/// 一般用于LiquidChart。一个Chart中可以有多个Vessel,Serie中用vesselIndex来对应。
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[ComponentHandler(typeof(VesselHandler), true)]
|
||||
public class Vessel : MainComponent, ISerieContainer
|
||||
{
|
||||
public enum Shape
|
||||
{
|
||||
/// <summary>
|
||||
/// 圆形
|
||||
/// </summary>
|
||||
Circle,
|
||||
/// <summary>
|
||||
/// 正方形。
|
||||
/// </summary>
|
||||
Rect,
|
||||
/// <summary>
|
||||
/// 三角形。
|
||||
/// </summary>
|
||||
Triangle,
|
||||
/// <summary>
|
||||
/// 菱形。
|
||||
/// </summary>
|
||||
Diamond,
|
||||
/// <summary>
|
||||
/// 不显示标记。
|
||||
/// </summary>
|
||||
None,
|
||||
}
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private Shape m_Shape = Shape.Circle;
|
||||
[SerializeField] private float m_ShapeWidth = 5f;
|
||||
[SerializeField] private float m_Gap = 5f;
|
||||
[SerializeField] private Color32 m_Color = new Color32(70, 70, 240, 255);
|
||||
[SerializeField] private Color32 m_BackgroundColor;
|
||||
[SerializeField] private bool m_AutoColor = true;
|
||||
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.45f };
|
||||
[SerializeField] private float m_Radius = 0.35f;
|
||||
[SerializeField] [Range(0.5f, 10f)] private float m_Smoothness = 1f;
|
||||
[SerializeField] private float m_Width = 0.5f;
|
||||
[SerializeField] private float m_Height = 0.7f;
|
||||
[SerializeField] private float[] m_CornerRadius = new float[] { 0, 0, 0, 0 };
|
||||
|
||||
public VesselContext context = new VesselContext();
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show the vessel.
|
||||
/// 是否显示容器组件。
|
||||
/// [defaut: true]
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The shape of vessel.
|
||||
/// 容器形状。
|
||||
/// [default: Shape.Circle]
|
||||
/// </summary>
|
||||
public Shape shape
|
||||
{
|
||||
get { return m_Shape; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Shape, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Thickness of vessel.
|
||||
/// 容器厚度。
|
||||
/// [defaut: 5f]
|
||||
/// </summary>
|
||||
public float shapeWidth
|
||||
{
|
||||
get { return m_ShapeWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ShapeWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The gap between the vessel and the liquid.
|
||||
/// 间隙。容器和液体的间隙。
|
||||
/// [defaut: 10f]
|
||||
/// </summary>
|
||||
public float gap
|
||||
{
|
||||
get { return m_Gap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The center of vesselß. The center[0] is the x-coordinate, and the center[1] is the y-coordinate.
|
||||
/// When value between 0 and 1 represents a percentage relative to the chart.
|
||||
/// 中心点。数组的第一项是横坐标,第二项是纵坐标。
|
||||
/// 当值为0-1之间时表示百分比,设置成百分比时表示图表宽高最小值的百分比。
|
||||
/// [default:[0.5f,0.45f]]
|
||||
/// </summary>
|
||||
public float[] center
|
||||
{
|
||||
get { return m_Center; }
|
||||
set { if (value != null) { m_Center = value; SetAllDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// The radius of vessel.
|
||||
/// When value between 0 and 1 represents a percentage relative to the chart.
|
||||
/// 半径。
|
||||
/// [default: 0.35f]
|
||||
/// </summary>
|
||||
public float radius
|
||||
{
|
||||
get { return m_Radius; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Radius, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The width of vessel.
|
||||
/// When value between 0 and 1 represents a percentage relative to the chart.
|
||||
/// 容器的宽。shape为Rect时有效。
|
||||
/// [default: 0.35f]
|
||||
/// </summary>
|
||||
public float width
|
||||
{
|
||||
get { return m_Width; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The height of vessel.
|
||||
/// When value between 0 and 1 represents a percentage relative to the chart.
|
||||
/// 容器的高。shape为Rect时有效。
|
||||
/// [default: 0.35f]
|
||||
/// </summary>
|
||||
public float height
|
||||
{
|
||||
get { return m_Height; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Height, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The smoothness of wave.
|
||||
/// 水波平滑度。
|
||||
/// [default: 1f]
|
||||
/// </summary>
|
||||
public float smoothness
|
||||
{
|
||||
get { return m_Smoothness; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Smoothness, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Background color of polar, which is transparent by default.
|
||||
/// 背景色,默认透明。
|
||||
/// [default: `Color.clear`]
|
||||
/// </summary>
|
||||
public Color32 backgroundColor
|
||||
{
|
||||
get { return m_BackgroundColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Vessel color. The default is consistent with Serie.
|
||||
/// 容器颜色。默认和serie一致。
|
||||
/// </summary>
|
||||
public Color32 color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether automatic color. If true, the color matches serie.
|
||||
/// 是否自动颜色。为true时颜色会和serie一致。
|
||||
/// [default: true]
|
||||
/// </summary>
|
||||
public bool autoColor
|
||||
{
|
||||
get { return m_AutoColor; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_AutoColor, 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)).
|
||||
/// 容器的圆角半径。用数组分别指定4个圆角半径(顺时针左上,右上,右下,左下)。shape为Rect时有效。
|
||||
/// </summary>
|
||||
public float[] cornerRadius
|
||||
{
|
||||
get { return m_CornerRadius; }
|
||||
set { if (PropertyUtil.SetClass(ref m_CornerRadius, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public bool IsPointerEnter()
|
||||
{
|
||||
return context.isPointerEnter;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 849f583b643a44246b3ec4abd7909b1b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,27 +0,0 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
public class VesselContext : MainComponentContext
|
||||
{
|
||||
/// <summary>
|
||||
/// the runtime center position of vessel.
|
||||
/// 运行时中心点。
|
||||
/// </summary>
|
||||
public Vector3 center { get; internal set; }
|
||||
/// <summary>
|
||||
/// the runtime radius of vessel.
|
||||
/// 运行时半径。
|
||||
/// </summary>
|
||||
public float radius { get; internal set; }
|
||||
/// <summary>
|
||||
/// The actual radius after deducting shapeWidth and gap.
|
||||
/// 运行时内半径。扣除厚度和间隙后的实际半径。
|
||||
/// </summary>
|
||||
public float innerRadius { get; internal set; }
|
||||
public float width { get; set; }
|
||||
public float height { get; set; }
|
||||
public bool isPointerEnter { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab0e7ad914ca24fcaa1fe470be695fd2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,24 +0,0 @@
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[UnityEngine.Scripting.Preserve]
|
||||
internal sealed class VesselHandler : MainComponentHandler<Vessel>
|
||||
{
|
||||
public override void Update()
|
||||
{
|
||||
if (chart.isPointerInChart)
|
||||
{
|
||||
component.context.isPointerEnter = false;
|
||||
return;
|
||||
}
|
||||
var vessel = component;
|
||||
vessel.context.isPointerEnter = vessel.show
|
||||
&& Vector3.Distance(vessel.context.center, chart.pointerPos) <= vessel.context.radius;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d52746e0238ff482589d37ee481394f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,36 +0,0 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
internal static class VesselHelper
|
||||
{
|
||||
public static Color32 GetColor(Vessel vessel, Serie serie, ThemeStyle theme, List<string> legendRealShowName)
|
||||
{
|
||||
if (serie != null && vessel.autoColor)
|
||||
{
|
||||
var colorIndex = legendRealShowName.IndexOf(serie.serieName);
|
||||
return SerieHelper.GetItemColor(serie, null, theme, colorIndex, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return vessel.color;
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateVesselCenter(Vessel vessel, Vector3 chartPosition, float chartWidth, float chartHeight)
|
||||
{
|
||||
if (vessel.center.Length < 2) return;
|
||||
var centerX = vessel.center[0] <= 1 ? chartWidth * vessel.center[0] : vessel.center[0];
|
||||
var centerY = vessel.center[1] <= 1 ? chartHeight * vessel.center[1] : vessel.center[1];
|
||||
var checkWidth = Mathf.Min(chartWidth, chartHeight);
|
||||
vessel.context.center = chartPosition + new Vector3(centerX, centerY);
|
||||
vessel.context.radius = ChartHelper.GetRuntimeRelativeOrAbsoluteValue(vessel.radius, checkWidth);
|
||||
vessel.context.innerRadius = vessel.context.radius - vessel.shapeWidth - vessel.gap;
|
||||
vessel.context.width = ChartHelper.GetRuntimeRelativeOrAbsoluteValue(vessel.width, checkWidth) - 2 * vessel.gap;
|
||||
vessel.context.height = ChartHelper.GetRuntimeRelativeOrAbsoluteValue(vessel.height, chartHeight) - 2 * vessel.gap;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d0abd225ece74e94b6f84034da63d13
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user