- Home /
Get last panel in chierarchy
Hello, I am trying to make simple system where: When player press "ESC", the last opened pannel will be closed. If there is no any pannels opened, main menu will pop up. Now question, which approach will be better:
1) Create list of gameObj in my ContainerManager Class, where when pannel will be open - add it to list, when closed, remove it from list, then just take last index when ESC will be pressed.
2) Use GetSiblingIndex method on panel transform and check if it equals last index in canvas childrens.
Waiting for advice.
Comment