修复Legend初始化异常的问题

This commit is contained in:
monitor1394
2020-04-09 07:26:40 +08:00
parent 6649059db1
commit 86403702e0
3 changed files with 14 additions and 17 deletions

View File

@@ -77,19 +77,22 @@ namespace XCharts
}
public static void HideAllObject(Transform parent, string match = null)
{
ActiveAllObject(parent, false, match);
}
public static void ActiveAllObject(Transform parent, bool active, string match = null)
{
for (int i = 0; i < parent.childCount; i++)
{
if (match == null)
SetActive(parent.GetChild(i), false);
//parent.GetChild(i).gameObject.SetActive(false);
SetActive(parent.GetChild(i), active);
else
{
var go = parent.GetChild(i);
if (go.name.StartsWith(match))
{
SetActive(go, false);
//go.gameObject.SetActive(false);
SetActive(go, active);
}
}
}
@@ -97,24 +100,17 @@ namespace XCharts
public static void DestroyAllChildren(Transform parent)
{
#if UNITY_2019_1_OR_NEWER
#else
if (parent == null) return;
#if UNITY_EDITOR && UNITY_2018_3_OR_NEWER
if (PrefabUtility.IsPartOfAnyPrefab(parent.gameObject))
var childCount = parent.childCount;
for (int i = childCount - 1; i >= 0; i--)
{
return;
}
#endif
while (parent.childCount > 0)
{
var go = parent.GetChild(0);
var go = parent.GetChild(i);
if (go != null)
{
GameObject.DestroyImmediate(go.gameObject);
//GameObject.Destroy(go.gameObject);
}
}
#endif
}
public static string GetFullName(Transform transform)