mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-20 23:40:10 +00:00
修复Legend的formatter设置为固定值时显示不正常的问题
This commit is contained in:
@@ -123,14 +123,14 @@ namespace XCharts.Runtime
|
||||
GameObject.DestroyImmediate(go.gameObject, true);
|
||||
}
|
||||
}
|
||||
public static void DestoryGameObjectByMatch(Transform parent, string match)
|
||||
public static void DestoryGameObjectByMatch(Transform parent, string containString)
|
||||
{
|
||||
if (parent == null) return;
|
||||
var childCount = parent.childCount;
|
||||
for (int i = childCount - 1; i >= 0; i--)
|
||||
{
|
||||
var go = parent.GetChild(i);
|
||||
if (go != null && go.name.StartsWith(match))
|
||||
if (go != null && go.name.Contains(containString))
|
||||
{
|
||||
GameObject.DestroyImmediate(go.gameObject, true);
|
||||
}
|
||||
@@ -281,7 +281,7 @@ namespace XCharts.Runtime
|
||||
return chartText;
|
||||
}
|
||||
|
||||
internal static Painter AddPainterObject(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax,
|
||||
public static Painter AddPainterObject(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax,
|
||||
Vector2 pivot, Vector2 sizeDelta, HideFlags hideFlags, int siblingIndex)
|
||||
{
|
||||
var painterObj = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
|
||||
@@ -381,6 +381,41 @@ namespace XCharts.Runtime
|
||||
return label;
|
||||
}
|
||||
|
||||
public static ChartLabel AddChartLabel2(string name, Transform parent, LabelStyle labelStyle,
|
||||
ComponentTheme theme, string content, Color autoColor, TextAnchor autoAlignment = TextAnchor.MiddleCenter)
|
||||
{
|
||||
Vector2 anchorMin, anchorMax, pivot;
|
||||
var sizeDelta = new Vector2(labelStyle.width, labelStyle.height);
|
||||
var textStyle = labelStyle.textStyle;
|
||||
var alignment = textStyle.GetAlignment(autoAlignment);
|
||||
UpdateAnchorAndPivotByTextAlignment(alignment, out anchorMin, out anchorMax, out pivot);
|
||||
var vector0_5 = new Vector2(0.5f, 0.5f);
|
||||
var labelObj = AddObject(name, parent, vector0_5, vector0_5, vector0_5, sizeDelta);
|
||||
var label = GetOrAddComponent<ChartLabel>(labelObj);
|
||||
label.text = AddTextObject("Text", label.gameObject.transform, anchorMin, anchorMax, pivot,
|
||||
sizeDelta, textStyle, theme, autoColor, autoAlignment, label.text);
|
||||
label.icon = ChartHelper.AddIcon("Icon", label.gameObject.transform, labelStyle.icon);
|
||||
label.SetSize(labelStyle.width, labelStyle.height);
|
||||
label.SetTextPadding(labelStyle.textPadding);
|
||||
label.SetText(content);
|
||||
label.UpdateIcon(labelStyle.icon);
|
||||
if (labelStyle.background.show)
|
||||
{
|
||||
label.color = (!labelStyle.background.autoColor || autoColor == Color.clear) ?
|
||||
labelStyle.background.color : autoColor;
|
||||
label.sprite = labelStyle.background.sprite;
|
||||
label.type = labelStyle.background.type;
|
||||
}
|
||||
else
|
||||
{
|
||||
label.color = Color.clear;
|
||||
label.sprite = null;
|
||||
}
|
||||
label.transform.localEulerAngles = new Vector3(0, 0, labelStyle.rotate);
|
||||
label.transform.localPosition = labelStyle.offset;
|
||||
return label;
|
||||
}
|
||||
|
||||
private static void UpdateAnchorAndPivotByTextAlignment(TextAnchor alignment, out Vector2 anchorMin, out Vector2 anchorMax,
|
||||
out Vector2 pivot)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user