Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
32 lines (28 sloc)
711 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class ChildList : MonoBehaviour | |
{ | |
public List<Transform> Children; | |
// Start is called before the first frame update | |
void Awake() | |
{ | |
Children = new List<Transform>(); | |
GetRecursiveChildren(transform); | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
} | |
private void GetRecursiveChildren(Transform parenttransform) | |
{ | |
foreach (Transform child in parenttransform) | |
{ | |
Children.Add(child.transform); | |
if (child.transform.childCount > 0) | |
{ | |
GetRecursiveChildren(child); | |
} | |
} | |
} | |
} |