mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 17:30:10 +00:00
优化SerieLabelPool
This commit is contained in:
@@ -22,14 +22,15 @@ namespace XCharts
|
||||
GameObject element;
|
||||
if (m_Stack.Count == 0 || !Application.isPlaying)
|
||||
{
|
||||
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);
|
||||
element = CreateSerieLabel(name, parent, label, font, color, iconWidth, iconHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
element = m_Stack.Pop();
|
||||
if (element == null)
|
||||
{
|
||||
element = CreateSerieLabel(name, parent, label, font, color, iconWidth, iconHeight);
|
||||
}
|
||||
m_ReleaseDic.Remove(element.GetInstanceID());
|
||||
element.name = name;
|
||||
element.transform.SetParent(parent);
|
||||
@@ -44,6 +45,16 @@ namespace XCharts
|
||||
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)
|
||||
{
|
||||
ChartHelper.SetActive(element, false);
|
||||
|
||||
Reference in New Issue
Block a user