Bank Implemented, other components with 'ShowHideUI.cs' not functioning properly

Hi all. Ok so following along with the tutorial in the link below (by our amazing Brian Trotter), I managed to implement a banking system (which works after all 4 courses, if you dig deep into the comments):

However, I also ran into a generic issue, where any other UI Component that does not have a second UI to display (to fill up the other requirements of our inspector) will not work if we click our hotkeys. This includes our Trait Store, Quest Page and Pause Menu being inaccessible. How can we go around this?

LOL, this is actually an extension of the other topic…
Make sure that in both Start() and Toggle(), you null check otherInventoryContainer.

        public void Toggle()
        {
            uiContainer.SetActive(!uiContainer.activeSelf);
            if(otherInventoryContainer!=null) otherInventoryContainer.SetActive(false);
        }

That didn’t work :sweat_smile: - any other potential solutions?

If that wasn’t it, then I’ll need to know more about what’s not working…
Are you getting errors in the inspector? Include the stack info.

Sure, here you go (First problem is for the ‘Trait’ T hotkey. Second one is for the ‘Quest’ Q hotkey, and the last one is the Escape button to open the pause menu of the game:

and all of them write this error in the stack trace:

UnassignedReferenceException: The variable otherInventoryContainer of ShowHideUI has not been assigned.
You probably need to assign the otherInventoryContainer variable of the ShowHideUI script in the inspector.
GameDevTV.UI.ShowHideUI.Update () (at Assets/GameDev.tv Assets/Scripts/UI/ShowHideUI.cs:31)

And when I click on it, it leads to the ‘SetActive()’ line of ShowHideUI.Update():

line31 ShowHideUI

Is your Update() manipulating the otherInventoryContainer? It should just be calling Toggle if the key is pressed.
Go through your ShowHideUI script.
Anywhere that references the otherInventoryContainer should be wrapped in

if(otherInventoryContainer!=null)
{
    //do something with otherInventoryContainer
}

Yup, that did fix it. I didn’t put the ‘if’ statement for my otherInventoryContainer in the Update function. Thanks again for saving my day :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms