I strongly believe this is an issue with unity, or my own fundamental understanding of it.
Simply put: I have two panels which have buttons. When you press a button, it changes its parent to the other panel. The problem is, the change is only VISUAL. This is proven through Debug.Log(). Even though the object is CLEARLY under panel 2 in the inspector, it prints panel 1 as the parent.
The workaround? Selecting the game object, repeat above process - it now works how I expect it to, printing out the correct parent. Confused af.
I figured out what was causing it, and it makes even less sense. It’s caused by KeyCode.Return specifically. The issue was solved when I switched it to any other key except that one.
Somehow KeyCode.Return acts as a mouseclick when its pressed, not just what’s over the mouse, but anywhere on the display.
So now, buttons are switching panels when I press the return key, despite KeyCode.Return not occuring ANYWHERE IN MY CODE. How could this be happening?
The solution for problem 2 is in this thread. Enter and return key act as a full screen mouse click by unity default. Return key triggering a button OnClick?