mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-18 14:30:10 +00:00
fix destroying a gameobject inside a prefab
This commit is contained in:
committed by
monitor1394
parent
e01c55c3ca
commit
773cfe6c7d
@@ -96,7 +96,7 @@ namespace XCharts
|
||||
var btnPanel = transform.Find("chart_list");
|
||||
m_BtnClone = transform.Find("btn_clone").gameObject;
|
||||
m_BtnClone.SetActive(false);
|
||||
ChartHelper.DestoryAllChilds(btnPanel);
|
||||
//ChartHelper.DestroyAllChildren(btnPanel);
|
||||
foreach (var module in m_ChartModule)
|
||||
{
|
||||
var btnName = "btn_" + module.name;
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace XCharts
|
||||
totalLegend++;
|
||||
}
|
||||
m_Legend.RemoveButton();
|
||||
ChartHelper.DestoryAllChilds(legendObject.transform);
|
||||
ChartHelper.DestroyAllChildren(legendObject.transform);
|
||||
if (!m_Legend.show) return;
|
||||
for (int i = 0; i < datas.Count; i++)
|
||||
{
|
||||
@@ -289,7 +289,7 @@ namespace XCharts
|
||||
{
|
||||
var labelObject = ChartHelper.AddObject(s_SerieLabelObjectName, transform, chartAnchorMin,
|
||||
chartAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
|
||||
ChartHelper.DestoryAllChilds(labelObject.transform);
|
||||
// ChartHelper.DestroyAllChildren(labelObject.transform);
|
||||
int count = 0;
|
||||
for (int i = 0; i < m_Series.Count; i++)
|
||||
{
|
||||
|
||||
@@ -72,12 +72,12 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public static void DestoryAllChilds(Transform parent)
|
||||
public static void DestroyAllChildren(Transform parent)
|
||||
{
|
||||
while (parent.childCount > 0)
|
||||
{
|
||||
var go = parent.GetChild(0);
|
||||
if (go.childCount > 0) DestoryAllChilds(go);
|
||||
if (go.childCount > 0) DestroyAllChildren(go);
|
||||
else GameObject.DestroyImmediate(go.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user