mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-26 10:50:08 +00:00
修复Label在初始化时会堆积的问题
This commit is contained in:
@@ -86,7 +86,7 @@ namespace XCharts.Runtime
|
|||||||
content, Color.clear, TextAnchor.MiddleCenter);
|
content, Color.clear, TextAnchor.MiddleCenter);
|
||||||
var pos = MarkLineHelper.GetLabelPosition(data);
|
var pos = MarkLineHelper.GetLabelPosition(data);
|
||||||
label.SetIconActive(false);
|
label.SetIconActive(false);
|
||||||
label.SetActive(data.label.show && data.runtimeInGrid);
|
label.SetActive(data.label.show && data.runtimeInGrid, true);
|
||||||
label.SetPosition(pos);
|
label.SetPosition(pos);
|
||||||
data.runtimeLabel = label;
|
data.runtimeLabel = label;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ namespace XCharts.Runtime
|
|||||||
private Align m_Align = Align.Left;
|
private Align m_Align = Align.Left;
|
||||||
private Image m_IconImage;
|
private Image m_IconImage;
|
||||||
private bool m_Active = true;
|
private bool m_Active = true;
|
||||||
private bool m_WakeActive = true;
|
|
||||||
|
|
||||||
public Image icon
|
public Image icon
|
||||||
{
|
{
|
||||||
@@ -57,7 +56,7 @@ namespace XCharts.Runtime
|
|||||||
protected override void Awake()
|
protected override void Awake()
|
||||||
{
|
{
|
||||||
raycastTarget = false;
|
raycastTarget = false;
|
||||||
SetActive(m_WakeActive, true);
|
m_Active = ChartHelper.IsActiveByScale(gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetTextPadding(TextPadding padding)
|
public void SetTextPadding(TextPadding padding)
|
||||||
@@ -203,7 +202,6 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
public void SetActive(bool flag, bool force = false)
|
public void SetActive(bool flag, bool force = false)
|
||||||
{
|
{
|
||||||
m_WakeActive = flag;
|
|
||||||
if (m_Active == flag && !force) return;
|
if (m_Active == flag && !force) return;
|
||||||
if (ChartHelper.SetActive(gameObject, flag))
|
if (ChartHelper.SetActive(gameObject, flag))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,6 +41,23 @@ namespace XCharts.Runtime
|
|||||||
return s_Builder.ToString();
|
return s_Builder.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsActiveByScale(GameObject gameObject)
|
||||||
|
{
|
||||||
|
if (gameObject == null) return false;
|
||||||
|
return IsActiveByScale(gameObject.transform);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsActiveByScale(Image image)
|
||||||
|
{
|
||||||
|
if (image == null) return false;
|
||||||
|
return IsActiveByScale(image.gameObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsActiveByScale(Transform transform)
|
||||||
|
{
|
||||||
|
return transform.localScale != Vector3.zero;
|
||||||
|
}
|
||||||
|
|
||||||
public static bool SetActive(GameObject gameObject, bool active)
|
public static bool SetActive(GameObject gameObject, bool active)
|
||||||
{
|
{
|
||||||
if (gameObject == null) return false;
|
if (gameObject == null) return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user