Setup your UI for navigation and use with keyboard and controller in Unity

preview_player
Показать описание
In this tutorial, you will learn how to set up a UI Navigation by keyboard and gamepad in Unity. You'll see how to configure the Event System, adjust automatic versus explicit navigation and add simple code in case you want to constrain the user to certain menu parts or pick the next element to select when the player presses a button. Whether you're organizing a basic main menu or a more complex system, this step-by-step guide shows you how to create a user interface that behaves exactly as intended.

This tutorial is all about creating a functional UI your users can navigate by keyboard or controller. It covers:
- The built-in Unity navigation system
- Setting up an initial gameobject to highlight
- Working with selectables
- How to make a menu circle around
- Working with explicit navigation vs automatic navigation
- Pitfalls of automatic navigation
- How to set an element to select by code
- How to constrain a user to one menu/part of the UI
- How to prevent de-selecting elements

Hope you'll enjoy it!

💬 Discord 💛

📖 Github

💸In case you'd like to support what I do

🛍️ Affiliate links 🛍️
If you'd like to support my channel, please use my affiliate links when buying cool stuff:

🌟 Need help with your project's UI?🧠
I have been a designer for more than 15 years, a teacher for three and I offer paid consulting for your project! You can find all the information here:
I am looking forward to hearing from you 💛

📖 Chapters
00:00 The result of this UI Navigation Tutorial
00:23 Scene Setup
01:18 How to enable keyboard and controller input on UI
02:33 How to make a menu circle around (Explicit Navigation)
05:40 Fixing the order elements get selected in (Automatic Navigation)
08:27 How to set a selected element by code
11:14 How to disable deselecting elements
12:17 The result and where to go next
Рекомендации по теме
Комментарии
Автор

This is an excellent tutorial.

As a somewhat experienced developer, I appreciate the lack of typing and just having the code explained. I get to see what you've done and that lets me replicate it in my own way.

10/10 tutorial.

HarithaNaurunna
Автор

Great tutorial. The EventSystem object has a "Deselect On Background" click flag that can be disabled to prevent deselecting a selectable object by clicking on a non-selectable object that is very handy. However, what you built also helps if you do want to support deselecting an object while using Mouse controls and remember where you were last when switching back to gamepad or keyboard.

nerusongear
Автор

I'm not on Unity anymore (went to Rust\Bevy since what happened) but I still watch your content sometimes in hope it supports your channel. Fortunately you share a lot of good advice which are applicable with different programming languages 👌😁 Thank you for that!

swalscha
Автор

So much quality in your tutorial: voice, explation, video! I just want to listen to every video, and have the best menu!
Thanks a lot, I will check every videos for sure!

slmbs-games
Автор

🔥 thanks! I know I'm going to be watching this and most of the other videos mentioned again in the upcoming year.

alexleonardkrea
Автор

Thanks for the tutorial, as helpful as always! The "click first on none, then on explicit" part baffled me. I would've been stuck there for ages wondering why I don't see what I'm supposed to...

Kirlyan
Автор

This is nice! But I would like to see this system with a dynamic UI, for example a quest journal (main and side quests). Both lists would be empty at first and would be filled by accepting new quests, so you can't really set up an explicit navigation to each interacting element.

campiinz
Автор

Hi!

I`m shocked how usefull your videos!
Thanks a lot of for you content. Instant subscribe <3

P.S. Going to watch all videos on your chanel

konyashary
Автор

Ah, dang, I was hoping for a UI toolkit tutorial 😅

yoko-kun
Автор

Thank you Christina. I've always just clicked none. I never bothered to learn about the other options.

leedavis
Автор

hey, what ui for unity do you use here? i see many helpful icons next to the objects in the hierachy for example or in the project folder and there are also nice header colors.

goldspitz
Автор

First of all, thanks for the tutorial! The script Was EXACTLY what I was looking for!
I only added an "if in the update function to encapsulate the other 3 if statements to optimize a tiny bit.

But I was wondering what would happen if you click on the start or quit buttons of the Main menu while the options menu is open?
There's also something about the unity selection system that annoys me. When you hover with your mouse over the buttons, the "Highlighted color" of the buttons reacts accordingly, but when you navigate through them with the keyboard the "Selected color" is the one that reacts to it, not the highlighted color :/

IjimeCore
Автор

Can it also works with gamepad, that ?

vik
Автор

Why do you hate the word "arrow" 😁?

syn
join shbcf.ru