fix destroying a gameobject inside a prefab

This commit is contained in:
Jacob Rapoport
2019-10-27 09:05:50 -07:00
committed by monitor1394
parent e01c55c3ca
commit 773cfe6c7d
3 changed files with 5 additions and 5 deletions

View File

@@ -96,7 +96,7 @@ namespace XCharts
var btnPanel = transform.Find("chart_list"); var btnPanel = transform.Find("chart_list");
m_BtnClone = transform.Find("btn_clone").gameObject; m_BtnClone = transform.Find("btn_clone").gameObject;
m_BtnClone.SetActive(false); m_BtnClone.SetActive(false);
ChartHelper.DestoryAllChilds(btnPanel); //ChartHelper.DestroyAllChildren(btnPanel);
foreach (var module in m_ChartModule) foreach (var module in m_ChartModule)
{ {
var btnName = "btn_" + module.name; var btnName = "btn_" + module.name;

View File

@@ -213,7 +213,7 @@ namespace XCharts
totalLegend++; totalLegend++;
} }
m_Legend.RemoveButton(); m_Legend.RemoveButton();
ChartHelper.DestoryAllChilds(legendObject.transform); ChartHelper.DestroyAllChildren(legendObject.transform);
if (!m_Legend.show) return; if (!m_Legend.show) return;
for (int i = 0; i < datas.Count; i++) for (int i = 0; i < datas.Count; i++)
{ {
@@ -289,7 +289,7 @@ namespace XCharts
{ {
var labelObject = ChartHelper.AddObject(s_SerieLabelObjectName, transform, chartAnchorMin, var labelObject = ChartHelper.AddObject(s_SerieLabelObjectName, transform, chartAnchorMin,
chartAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight)); chartAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
ChartHelper.DestoryAllChilds(labelObject.transform); // ChartHelper.DestroyAllChildren(labelObject.transform);
int count = 0; int count = 0;
for (int i = 0; i < m_Series.Count; i++) for (int i = 0; i < m_Series.Count; i++)
{ {

View File

@@ -72,12 +72,12 @@ namespace XCharts
} }
} }
public static void DestoryAllChilds(Transform parent) public static void DestroyAllChildren(Transform parent)
{ {
while (parent.childCount > 0) while (parent.childCount > 0)
{ {
var go = parent.GetChild(0); var go = parent.GetChild(0);
if (go.childCount > 0) DestoryAllChilds(go); if (go.childCount > 0) DestroyAllChildren(go);
else GameObject.DestroyImmediate(go.gameObject); else GameObject.DestroyImmediate(go.gameObject);
} }
} }