mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-31 05:48:45 +00:00
性能优化
This commit is contained in:
@@ -217,6 +217,7 @@ namespace XCharts
|
|||||||
m_AxisName.Copy(other.axisName);
|
m_AxisName.Copy(other.axisName);
|
||||||
m_AxisLabel.Copy(other.axisLabel);
|
m_AxisLabel.Copy(other.axisLabel);
|
||||||
m_Data.Clear();
|
m_Data.Clear();
|
||||||
|
m_Data.Capacity = m_Data.Count;
|
||||||
foreach (var d in other.data) m_Data.Add(d);
|
foreach (var d in other.data) m_Data.Add(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -643,6 +644,7 @@ namespace XCharts
|
|||||||
axis.axisName.Copy(axisName);
|
axis.axisName.Copy(axisName);
|
||||||
axis.axisLabel.Copy(axisLabel);
|
axis.axisLabel.Copy(axisLabel);
|
||||||
axis.data.Clear();
|
axis.data.Clear();
|
||||||
|
axis.data.Capacity = data.Count;
|
||||||
foreach (var d in data) axis.data.Add(d);
|
foreach (var d in data) axis.data.Add(d);
|
||||||
return axis;
|
return axis;
|
||||||
}
|
}
|
||||||
@@ -694,6 +696,7 @@ namespace XCharts
|
|||||||
axis.axisName.Copy(axisName);
|
axis.axisName.Copy(axisName);
|
||||||
axis.axisLabel.Copy(axisLabel);
|
axis.axisLabel.Copy(axisLabel);
|
||||||
axis.data.Clear();
|
axis.data.Clear();
|
||||||
|
axis.data.Capacity = data.Count;
|
||||||
foreach (var d in data) axis.data.Add(d);
|
foreach (var d in data) axis.data.Add(d);
|
||||||
return axis;
|
return axis;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,19 @@ namespace XCharts
|
|||||||
public static float CRICLE_SMOOTHNESS = 2f;
|
public static float CRICLE_SMOOTHNESS = 2f;
|
||||||
private static UIVertex[] vertex = new UIVertex[4];
|
private static UIVertex[] vertex = new UIVertex[4];
|
||||||
|
|
||||||
|
public static void SetActive(GameObject gameObject,bool active){
|
||||||
|
SetActive(gameObject.transform,active);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通过设置scale实现是否显示,优化性能,减少GC
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="transform"></param>
|
||||||
|
/// <param name="active"></param>
|
||||||
|
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)
|
public static void HideAllObject(GameObject obj, string match = null)
|
||||||
{
|
{
|
||||||
HideAllObject(obj.transform, match);
|
HideAllObject(obj.transform, match);
|
||||||
@@ -22,13 +35,15 @@ namespace XCharts
|
|||||||
for (int i = 0; i < parent.childCount; i++)
|
for (int i = 0; i < parent.childCount; i++)
|
||||||
{
|
{
|
||||||
if (match == null)
|
if (match == null)
|
||||||
parent.GetChild(i).gameObject.SetActive(false);
|
SetActive(parent.GetChild(i),false);
|
||||||
|
//parent.GetChild(i).gameObject.SetActive(false);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var go = parent.GetChild(i);
|
var go = parent.GetChild(i);
|
||||||
if (go.name.StartsWith(match))
|
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 = parent.Find(name).gameObject;
|
||||||
obj.SetActive(true);
|
obj.SetActive(true);
|
||||||
obj.transform.localPosition = Vector3.zero;
|
obj.transform.localPosition = Vector3.zero;
|
||||||
|
obj.transform.localScale = Vector3.one;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user