mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-29 20:58:47 +00:00
优化SerieLabelPool
This commit is contained in:
@@ -22,14 +22,15 @@ namespace XCharts
|
|||||||
GameObject element;
|
GameObject element;
|
||||||
if (m_Stack.Count == 0 || !Application.isPlaying)
|
if (m_Stack.Count == 0 || !Application.isPlaying)
|
||||||
{
|
{
|
||||||
element = ChartHelper.AddSerieLabel(name, parent, font,
|
element = CreateSerieLabel(name, parent, label, font, color, iconWidth, iconHeight);
|
||||||
color, label.backgroundColor, label.fontSize, label.fontStyle, label.rotate,
|
|
||||||
label.backgroundWidth, label.backgroundHeight, 1);
|
|
||||||
ChartHelper.AddIcon("Icon", element.transform, iconWidth, iconHeight);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
element = m_Stack.Pop();
|
element = m_Stack.Pop();
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
element = CreateSerieLabel(name, parent, label, font, color, iconWidth, iconHeight);
|
||||||
|
}
|
||||||
m_ReleaseDic.Remove(element.GetInstanceID());
|
m_ReleaseDic.Remove(element.GetInstanceID());
|
||||||
element.name = name;
|
element.name = name;
|
||||||
element.transform.SetParent(parent);
|
element.transform.SetParent(parent);
|
||||||
@@ -44,6 +45,16 @@ namespace XCharts
|
|||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static GameObject CreateSerieLabel(string name, Transform parent, SerieLabel label, Font font, Color color,
|
||||||
|
float iconWidth, float iconHeight)
|
||||||
|
{
|
||||||
|
var element = ChartHelper.AddSerieLabel(name, parent, font,
|
||||||
|
color, label.backgroundColor, label.fontSize, label.fontStyle, label.rotate,
|
||||||
|
label.backgroundWidth, label.backgroundHeight, 1);
|
||||||
|
ChartHelper.AddIcon("Icon", element.transform, iconWidth, iconHeight);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
public static void Release(GameObject element)
|
public static void Release(GameObject element)
|
||||||
{
|
{
|
||||||
ChartHelper.SetActive(element, false);
|
ChartHelper.SetActive(element, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user