mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-19 15:00:08 +00:00
优化清空并重新添加数据后的自动刷新问题
This commit is contained in:
@@ -14,6 +14,7 @@ namespace XCharts
|
||||
internal static class SerieLabelPool
|
||||
{
|
||||
private static readonly Stack<GameObject> m_Stack = new Stack<GameObject>(200);
|
||||
private static Dictionary<int, bool> m_ReleaseDic = new Dictionary<int, bool>(1000);
|
||||
|
||||
public static GameObject Get(string name, Transform parent, SerieLabel label, Font font, Color color,
|
||||
float iconWidth, float iconHeight)
|
||||
@@ -29,6 +30,7 @@ namespace XCharts
|
||||
else
|
||||
{
|
||||
element = m_Stack.Pop();
|
||||
m_ReleaseDic.Remove(element.GetInstanceID());
|
||||
element.name = name;
|
||||
element.transform.SetParent(parent);
|
||||
element.transform.localEulerAngles = new Vector3(0, 0, label.rotate);
|
||||
@@ -45,10 +47,12 @@ namespace XCharts
|
||||
public static void Release(GameObject element)
|
||||
{
|
||||
ChartHelper.SetActive(element, false);
|
||||
//if (m_Stack.Count > 0 && ReferenceEquals(m_Stack.Peek(), element))
|
||||
// Debug.LogError("Internal error. Trying to destroy object that is already released to pool." + element.name);
|
||||
if (Application.isPlaying)
|
||||
if (!Application.isPlaying) return;
|
||||
if (!m_ReleaseDic.ContainsKey(element.GetInstanceID()))
|
||||
{
|
||||
m_Stack.Push(element);
|
||||
m_ReleaseDic.Add(element.GetInstanceID(), true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ReleaseAll(Transform parent)
|
||||
@@ -63,6 +67,7 @@ namespace XCharts
|
||||
public static void ClearAll()
|
||||
{
|
||||
m_Stack.Clear();
|
||||
m_ReleaseDic.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user