I somewhat understand what this error means, but I'm not sure exactly how to fix it.
This is the script I have the error on:
public class LimitChildAmount : MonoBehaviour
{
public GameObject Hand;
public int maxChildAmount = 1;
void Update()
{
if (transform.childCount > maxChildAmount)
{
for (int i = maxChildAmount; i < transform.childCount; i++)
{
transform.GetChild(i).SetParent(Hand);
}
}
}
}
I'm getting the script on (20,49), where it says "transform.GetChild(i).SetParent(Hand);"
"Hand" in this context is a canvas panel in my hierarchy I'm trying to access through the script so that when a gameobject that isn't allowed to enter the tabletop slot (the object this script is attached to) it returns to the Hand. When I tried saving this to see if it worked, it gave me this error. If anyone could help that would be great.
(I'm trying to keep the question simple because I wasn't sure what would be useful for you to know and what wouldn't, so I left a lot of context out. If something's confusing, let me know and I'll explain.)
↧