Change explicit navigation via UnityScript

Hello! I have a situation where I’d like the top button in the vertical “upgrade” list to go back to the previously selected ship from the top horizontal row, when the up button is pressed.

To do this, I just need to change the explicit navigation for the upgrade button . I’ve got the code below, but I get a Null reference exception and I think it’s because I’m not sure what “.selectable” means in the script references.

Anyone know where I may be going wrong?

weaponUpgrade.GetComponent(UI.Navigation).selectOnUp = shipButtons[shipToUse].GetComponent(UI.Button);
var navigation = weaponUpgrade.GetComponent(UI.Selectable).navigation;
navigation.selectOnUp = shipButtons[shipToUse].GetComponent(UI.Button);
weaponUpgrade.GetComponent(UI.Selectable).navigation = navigation;
4 Likes

Awesome, thanks Tim! Side note, maybe obvious but at first I made this mistake, make sure the transitions are set to Explicit for that button.