Forum rules - please read before posting.

Where to place custom scripts for UI/Menus

I know this question will have many different subjective answers, but I wanted to get other people's ideas on what they think is best practice when it comes to the location for custom menu scripts.

I have tried to centralise all of my custom menu functionality into one script "CustomUIManager.cs" and I have placed it as a component on my InGame menu, which is always present in my game scenes. This is where I put my listeners for mouse over and click events etc.

I was going to use MenuSystem.cs, as that is always present on the GameEngine prefab, but I wasn't sure if this was a good idea or not.

Comments

  • The MenuSystem is really more of a legacy component at this point.  The recommended way to work with Menus and custom scripts is to use custom events.

    Menus have a number of custom events that you can use to have code run when one is clicked or mouse-overed - see the "Menu Scripting" chapter of the Manual.
  • Yes, I'm aware of custom events.
    I suppose my question was really where the best place those listener functions/scripts should live. I was thinking of having a single 'manager' script that listens for those events and manipulates all different ui components. But then the menu system (as it lives on the game engine prefab) seemed like an already great spot for it, but wasn't sure if itll be deprecated or not.
  • @ezsilman I tend to make my own persistent engine where I put all my managers scripts (modifying AC's scripts will make updating harder later, so I don't recommend it unless it's really necessary). You could make a gameobject prefab, put it on a Resources folder, then either instantiate that at runtime using Resources.load or place it manually on the first scene. You can then use Don't Destroy on Load on the Awake of your main manager, it if it suits your needs to make it really persistent. That way you have a single object to place your managers, and it won't get overwritten when AC updates. At one point, I also just placed my scripts on AC's persistent engine prefab, but it was an issue when updating, this has worked better (in my case).
  • Thanks Alverik. Good point!
    Where do you instantiate the pre fab?
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.