I'm creating custom menu parts by extending BaseMenuPart along with some of the IUI interfaces.

The methods for closing the menu part are as follows:

public void BoxClosed(IUIBox origin)
{
this.infoDisplay.UnregisterChanges();

if (origin == this.attributeBox)
{
attributeBox = null;
}
}
public override void Close(bool closeImmediately)
{
if (UIBoxSetting.IsActive(this.attributeBox))
{
if (closeImmediately)
{
this.infoDisplay.UnregisterChanges();
this.attributeBox.Control = null;
this.attributeBox.CloseImmediately();
this.attributeBox = null;
}
else
{
attributeBox.Close();
}
}
}


However when I press the close button (I'm using 2nd call closes), the inputs of the UIBox are wiped clean leaving the background of the box left over, as well as the background UI. Pictures are as follows:

Menu active:

image

Menu closed:

image

I'm really not sure why its not closing properly. My other inputs close and I am mimicking their close functions.
Any ideas would be appreciated. I can of course post more code.

  • Im using multiple menu parts and by removing the extra menu parts and leaving only this part activated I can indeed confirm that it closes. Is there something I am missing about the functionality of multiple menu parts each extending IUI interfaces and BaseMenuPart?
  • Ok so I found what line of code was causing the UI box to stay generated. I forgot to add a check to see if attributeBox was null before creating the IUIBox.

    if (this.attributeBox == null || this.attributeBox.IsClosingOrClosed)
    {
    //Background UI box
    attributeBox = attributeButtonUIBox.Create();
    }


    However the background UI still does not close when I press the close button and I am trying to figure out why.
  • If i insert the line

    this.screen.CloseImmediate();

    underneath attributeBox.Close() the background closes as well and the menu functions normally.

    Is there a reason that the background isn't closing when I press the close key with 3 menu parts attached, 2 of them custom (1 custom one is essentially just a single button rather than a button list)? Kinda pointless to include when you could just use a button list with a single item, but I dunno, I seperated it out. It seems like the close function of the background UI just isn't being called and after messing with settings I haven't found a solution other than inserting the line above.
  • edited April 2022
    So fixed the background not closing by switching from a general background to a default background. However now when i close the menu I lose control of the game, as if it never sets itself to the closed state. Upon reviewing the source code I found exactly that. The close method never ends with the menuStatus variable being set to MenuStatus.Closed. As a result I am unable to open and close the menu.

    A simple one line change to the source code fixes this but I should bring it to your attention because it seems to have been missed. Image attached (if you can zoom in and read the font, basically its the Close() and DoCloseFades() methods of the MenuScreen class)

    image

    Alternatively I suppose you could put the line of code at the end of the close function.
    Post edited by Vanisle on
  • Better yet call FinishClosing() to seal the deal
  • So, all fixed?
    Otherwise I'd probably need to see more of your code to see what's going on. Regarding backgrounds, did you add your own backgrounds code to your menu part or are you refering to the menu screen's background settings?
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Menu screen's background settings. At first I had a general background set up and it seemed that just pressing the close button would only close 1 UI element leaving the rest, including the background open. After switching to a default background everything closed properly except after it closed I couldn't reopen the menu or control my character.

    Adding the FinishClosing line fixed everything.
Sign In or Register to comment.