Hi there - I'm using ORK 2.33 and I'm really enjoying all it has to offer. I was wondering if you could help me with one problem I've been wrestling with though. I'm using the 'New GUI' option and have a menu that I'm trying to populate with custom button entries when the menu is opened. I love having ORK managing menus for me so I'm keen to integrate as much as possible!

My first thought was that this might be doable via Events. I can of course run an event with a 'Function to Variable' node when the menu is opened, which I'm using to good effect in other areas. As this is for simple data types though, I'm not sure this is appropriate here. I also couldn't find a way to pipe content out to update a menu's button list via an event. Is there something I'm missing in the UI events that I could use for this?

Alternatively, I've tried a different approach, where I've used a custom GUI Box prefab for the menu screen in question, which holds a setup script. This is successfully being executed when the menu is opened or re-enabled.

From the setup script, I can grab references to the GUIBoxComponent of the menu and the ScrollRect housing its content. I can add my buttons by instantiating prefabs, setting up their details and adding them as children of the menu's ScrollRect content. This does add the buttons to the correct menu positions, but they're essentially inactive and the ORK menu has no idea they're there, so there's no navigation controls or scrollbar added.

I've tried a whole slew of options, broadly involving combinations of the following steps:
- Creating my button object and doing it's initial onclick setup and positioning
- Adding a UIPoolComponent to it and setting its prefab
- Adding a GUIContent to it and setting its texture, then creating a ChoiceContent from that
- Adding a UIClickComponent to it
- Adding a UIChoiceButtonComponent to it and initializing it using the GUIBox, ChoiceContent, Prefab button etc... (though not quite sure what to use for the NewUIButtonSettings and NewUIChoiceButtonEvents here)
- Running UpdateBox/UpdateColors/ToPoolRecalculate against the GUIBoxComponent / settings its 'ContentUpdated' flag to true

Each of these elements looks to be involved, but I've not cracked it yet. I'm essentially black boxing for testing the results which is what has prompted me to make a post and see if I can get a steer on this. Am I anywhere close with any of the above or is this an inappropriate way to go about this?

I've read pretty much everything related that I could find on the forums and understand that what I likely need to do is implement the IChoice interface somewhere to handle controls on the menu. I was hoping to avoid this by piping buttons into an existing menu rather than implementing a new menu type, but would this be the best way to go?

From digging around the source code, I notice that it is the menu parts (e.g. ButtonListMenuPart) that implement IChoice. Am I right in thinking that I could use one of these as a template to build my own menu part and have this initialize the menu with all of its required content, perhaps in its Show method? If I were to do this, would there be a way to add my custom menu part to the list of menu parts in the ORK Editor, or would I need to try and find a way to set it up and switch it in at runtime?

Anyway, I'm hoping I've outlined my plight sufficiently there. Apologies for the lengthy and fiddly question(s), but I'd really appreciate any assistance, examples or pointers you can give me. If I can crack this then I can think of an absolute ton of uses for it. Thanks for your time!
  • You can't add content at runtime - at least not in a way to have them be part of ORK's menu handling. Sure, you can spawn your custom buttons which do whatever you set them up to do (via code), but they can't really be handled by ORK in that case.

    If you just need e.g. a Button List to have different buttons in different stages of the game - that can be handled by the Requirements of the individual menu items in the list.

    You can also place custom UI stuff on the prefab of the used GUI box (i.e. the content box prefab).

    You can naturally also write a custom menu part - as long as it's descending from BaseMenuPart and has an ORKEditorHelp attribute added to the class (for the content information that's displayed in the part list) it'll show up in the editor.
    Probably best to just copy an existing menu part's code and alter it to your needs :)
    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!
  • Thanks for the steer! I'll have a think about how best to proceed - appreciate the input!
  • Just checking in to say thanks again for the steer. Building a custom menu part was significantly easier than the nonsense I had been trying and it's working great. Much appreciated!
  • You're welcome - many of ORK's system can actually be extended like this. E.g. if you need a custom status requirement you can do it the same way (just descending from a different base class) :)
    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!
  • You can naturally also write a custom menu part - as long as it's descending from BaseMenuPart and has an ORKEditorHelp attribute added to the class (for the content information that's displayed in the part list) it'll show up in the editor.
    Is there any documentation or tutorial somewhere I can look into creating custom menu parts??
  • No - I'd recommend to check out (or copy) the code of one of the existing menu parts to build upon.
    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!
Sign In or Register to comment.