Search Unity

Menu Heavy Game - Basic Framework / Design

Discussion in 'Game Design' started by goleminthegears, Aug 26, 2022.

  1. goleminthegears

    goleminthegears

    Joined:
    Dec 12, 2014
    Posts:
    13
    Hi,

    I'm looking to create a game like Coffee Talk, Strange Horticulture, Potion Craft. Is there a good framework or design patterns to follow or use?
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Hi,

    Start by using a tool like Figma to design your UI. You'll be able to iterate a lot faster than in Unity, and you can share your mock-ups to get feedback on them.

    There are some UI systems on the Asset Store that try to use a data-oriented design to present your UIs in a consistent manner, which is a good idea in concept. But before your commit to any of them, scrutinize the reviews and make your decision carefully. Once you commit, you'll be stuck with the way they work, issues and all. They may work great for you, or you may find it less much frustrating to handle it yourself. (That said, if you're set on using a framework, I've found that ZUI works well and is simple understand and set up. But that's just personal opinion.)

    If you're handy with scripting, you can write your own data-oriented UI system. Briefly, your data specifies what UI elements to show and what the elements should do, and your code assembles the UI to show them. The new UI Toolkit system might be a good fit for this. It has some limitations, but it's the direction Unity is heading in.

    If you'd prefer to minimize scripting, use nested prefabs and prefab variants for all UI elements. (A prefab variant is a prefab that's based on another prefab but applies some changes on top of the original prefab.) For example, make a prefab of your base button type. Whenever you add a button to a UI, use this prefab or a prefab variant. This way you can change the appearance of the prefab and it will automatically propagate to all instances of that prefab in all of your UIs.

    The Asset Store has some good UI transition assets that are more limited in scope and complexity than the wholesale UI systems I mentioned above. They can do basic things like making a button bounce when you mouse over it, or sliding one menu offscreen as another menu slides onscreen. Alternatively, look into tweening assets like DOTween. They can do the same thing but also tween non-UI elements, such as moving a GameObject across the screen or making it grow bigger or smaller.
     
    angrypenguin likes this.
  3. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    I was just mentioning this in another thread where someone asked a UI-related question. The main thing to me would be to learn about and apply the Single Responsibility Principle if you're not already.

    The second one I'd suggest is getting familiar with the Observer Pattern if you're not already. This way your UI elements don't have to keep checking on whatever data they're displaying, they can just know to update when it's actually changed.

    Finally, if you're coding your own framework, I'd suggest internally treating the set of open screens as a "stack" data structure. This is a pretty common approach, so there are plenty of places you can read about it.

    Otherwise, it's all about getting used to whatever tools you opt to use. They all have their quirks.

    One consideration is that if you go this route, use the newest version of Unity you can. Nested prefabs in particular have a few kinks which are only worked out in recent versions, such as the order of transforms getting mixed up, which will break anything you're doing with automated layouts if it happens.
     
    TonyLi likes this.