diff --git a/Scripts/UI/Component/Axis.cs b/Scripts/UI/Component/Axis.cs
index 7ede02a3..6d3b8c7f 100644
--- a/Scripts/UI/Component/Axis.cs
+++ b/Scripts/UI/Component/Axis.cs
@@ -217,6 +217,7 @@ namespace XCharts
m_AxisName.Copy(other.axisName);
m_AxisLabel.Copy(other.axisLabel);
m_Data.Clear();
+ m_Data.Capacity = m_Data.Count;
foreach (var d in other.data) m_Data.Add(d);
}
@@ -643,6 +644,7 @@ namespace XCharts
axis.axisName.Copy(axisName);
axis.axisLabel.Copy(axisLabel);
axis.data.Clear();
+ axis.data.Capacity = data.Count;
foreach (var d in data) axis.data.Add(d);
return axis;
}
@@ -694,6 +696,7 @@ namespace XCharts
axis.axisName.Copy(axisName);
axis.axisLabel.Copy(axisLabel);
axis.data.Clear();
+ axis.data.Capacity = data.Count;
foreach (var d in data) axis.data.Add(d);
return axis;
}
diff --git a/Scripts/UI/Utility/ChartHelper.cs b/Scripts/UI/Utility/ChartHelper.cs
index 056afd29..fabd6807 100644
--- a/Scripts/UI/Utility/ChartHelper.cs
+++ b/Scripts/UI/Utility/ChartHelper.cs
@@ -12,6 +12,19 @@ namespace XCharts
public static float CRICLE_SMOOTHNESS = 2f;
private static UIVertex[] vertex = new UIVertex[4];
+ public static void SetActive(GameObject gameObject,bool active){
+ SetActive(gameObject.transform,active);
+ }
+
+ ///
+ /// 通过设置scale实现是否显示,优化性能,减少GC
+ ///
+ ///
+ ///
+ public static void SetActive(Transform transform,bool active){
+ if(active) transform.localScale = Vector3.one;
+ else transform.localScale = Vector3.zero;
+ }
public static void HideAllObject(GameObject obj, string match = null)
{
HideAllObject(obj.transform, match);
@@ -22,13 +35,15 @@ namespace XCharts
for (int i = 0; i < parent.childCount; i++)
{
if (match == null)
- parent.GetChild(i).gameObject.SetActive(false);
+ SetActive(parent.GetChild(i),false);
+ //parent.GetChild(i).gameObject.SetActive(false);
else
{
var go = parent.GetChild(i);
if (go.name.StartsWith(match))
{
- go.gameObject.SetActive(false);
+ SetActive(go,false);
+ //go.gameObject.SetActive(false);
}
}
}
@@ -79,6 +94,7 @@ namespace XCharts
obj = parent.Find(name).gameObject;
obj.SetActive(true);
obj.transform.localPosition = Vector3.zero;
+ obj.transform.localScale = Vector3.one;
}
else
{