Easily Manage the State of Your UI With This Pattern to Save Yourself Headaches




Published: 23 Nov 2021

On your UI do you have references from random scripts to other scripts to manage which one should be showing? Are you setting up the state of the next page in code where your UI scripts are tightly coupled?


In this video I'll show you the pattern I've been using for the last 6 years to remove that mess and separate the concerns of UI Sounds and Animations into a "Page" Monobehaviour that is controlled by the MenuController. With these two simple, but powerful scripts you can easily manage your UI page state in a simple, predictable, and powerful way.


At the end of this video you'll have:

A structured, proven paradigm to approach to managing pages on your UI

An easy way to decouple your animation and sound playing from your UI logic.

A tool to intelligently control what needs to be set up, when it needs to be set up, instead of having that hard coded in your scripts.


🔶 ALL THINGS LlamAcademy now available at: https://llamacademy.dev/support including latest tutorials, courses, ways to support, and more! Check it out 🙂

👨‍💻 Get the FULL FREE PROJECT on GitHub: https://github.com/llamacademy/menu-controller

🏷️Save 25% on the ultimate C# IDE: JetBrains Rider with code LLAMACADEMY: https://www.jetbrains.com/store/?section=personal&billing=yearly


Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.


Chapters

00:00 Introduction - What to Expect

03:24 Scene Overview

03:44 Page.cs - Initial Setup, Entry and Exits

06:50 AnimationHelper.cs - Page Animations

07:43 Page.cs - Audio Management

09:22 Page.cs - Hooking up the rest of the animations

10:40 Page.cs - Fixing copy/paste issues

11:02 MenuController.cs - Pushing and Popping Pages

14:10 Hooking it all up

16:50 PlayerInput - Escape to go back

17:46 Demo

18:58 Page.cs - Adding Events Before/After Animations

19:21 Explanation of Event Order

19:45 Page.cs - Calling Events

20:21 Setting up Events in the Editor

20:57 Demo - Events and Exit On Page Push

Connect on Social Media

Some links may be affiliate links, which at no additional cost to you, gives LlamAcademy a small portion of the purchase.