- Home /
Question by
The-unknown-creator · Jul 15, 2021 at 02:10 AM ·
childrenamount
I'm trying to check everytime a gameobject childCount increases by 1 but it doesn't seem to work.
Heres what I'm trying to do.
void Update()
{
int childs = transform.childCount;
if(childs += 1)
{
AmountChanged = true;
}
}
Comment
Answer by unity_BUJQdslYm7EuFQ · Jul 15, 2021 at 12:41 PM
Problem is that you check a variable childs, not thransform.childCount
int childs;
void Start()
{
childs = transform.childCount;
}
void Update()
{
if(childs+1==transform.childCount)
{
AmountChanged = true;
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613040338im_/https://answers.unity.com/themes/thub/images/avi.jpg)