Hello guys!
I have a fairly “simple” question. Often I find myself writing very repetetive code, with tons of “if” statements. I’d just like to know how I am actually supposed to deal with this, and what way is the correct way to do it.
Example on repetetive code:
if (popUpPosition1.transform.childCount >= 2)
popUpPosition1.transform.GetChild(0).transform.SetParent(popUpPosition2.transform, false);
if (popUpPosition2.transform.childCount >= 2)
popUpPosition2.transform.GetChild(0).transform.SetParent(popUpPosition3.transform, false);
if (popUpPosition3.transform.childCount >= 2)
popUpPosition3.transform.GetChild(0).transform.SetParent(popUpPosition4.transform, false);
if (popUpPosition4.transform.childCount >= 2)
popUpPosition4.transform.GetChild(0).transform.SetParent(popUpPosition5.transform, false);
if (popUpPosition5.transform.childCount >= 2)
popUpPosition5.transform.GetChild(0).transform.SetParent(popUpPosition6.transform, false);
if (popUpPosition6.transform.childCount >= 2)
Destroy(popUpPosition6.transform.GetChild(0));
I’d just like to know what to use. A friend of mine told me something about having to learn “objects” but I am not entirely sure what he meant by that.
Thanks in advance!