반응형
https://zimamderotech.tistory.com/89
자식 객체 Destroy 할 때 주의
transform.childCount ------ (1) Destroy(child.gameObject) transform.childCount ------ (2) 위와 같이 자식 객체를 지웠을 때, (1)과 (2) 값은 같다. 화면에서도 지워야 chil..
zimamderotech.tistory.com
protected void RemoveAllChild(Transform targetParent)
{
var children = targetParent.transform.GetComponentsInChildren<Transform>(true);
foreach (var child in children)
{
if (child == targetParent) continue;
child.parent = null;
Destroy(child.gameObject);
}
}
반응형
'Unity > Unity 이슈' 카테고리의 다른 글
[Unity] Package Mannger 버전 올리기 (0) | 2022.11.30 |
---|---|
Unity Build 에러 (0) | 2022.11.24 |
싱글톤 GameObject가 계속 늘어날 때 (0) | 2022.03.27 |
[Addressable] JSON parse error: Invalid value. (0) | 2022.02.27 |
[구글로그인] DEBUG: Authentication canceled (0) | 2022.02.27 |