Handle UI Like a Commercial Game (Custom Animations + Different Control Schemes) | Unity Tutorial
Ойындар
Show your Support & Get Exclusive Benefits on Patreon (Including Access to this project's Source Files + Code) - www.patreon.com/sasquatchbgames
Join our Discord Community! - discord.com/invite/aHjTSBz3jH
In this Unity tutorial, you'll learn about Unity's handy Selectable interfaces (like ISelectHandler, IPointerEnterHandler, etc) and how to utilize these to create custom UI animations. After that we'll look at how to handle things like swapping control schemes mid-UI screen and how we can still seamlessly navigate around.
Link to Download our FREE 2D Asset Pack:
veilofmaia.com/tutorial-asset-pack/
---
In need of some Unity Assets? Using our affiliate link is a great way to support us. It's free, and we get a small cut that helps keep us up and running: assetstore.unity.com?aid=1100lwgBQ
---
Unity Selectable Documentation:
docs.unity3d.com/2017.4/Documentation/ScriptReference/UI.Selectable.html
Unity Free Cards on the Asset Store
assetstore.unity.com/packages/2d/gui/card-shirts-lite-165698?aid=1100lwgBQ
Contents of This Video: ------------------------------------------
00:00 - Intro
01:31 - Different Interactable Transitions
02:29 - Creating a UI animation with code
04:28 - Adding Selectable Interfaces so we know when the card has been selected
06:33 - Adding Controls for Gamepad or Keyboard
08:40 - Tracking which object should be selected with gamepad
09:54 - Setting Up UI Input controls
10:42 - Finishing up
Who We Are-------------------------------------
If you're new to our channel, we're Brandon & Nikki from Sasquatch B Studios. We sold our house to start our game studio, and work full time on building our business and making our game, Veil of Maia.
Wishlist our Games:
Wishlist Veil of Maia! - store.steampowered.com/app/1948230/Veil_of_Maia/
Wishlist Samurado!
store.steampowered.com/app/2343270/Samurado/
Don't forget to Subscribe for NEW game dev videos every Monday & Thursday!
Follow us on Twitter for regular updates!
SasquatchBGames
#unitytutorial #unity2d #unity3d
Пікірлер: 72
YES! please make a series called (Like a Commercial Game) THIS IS SOOO HELPFUL!
@lecomingbegend497
4 күн бұрын
This should be pinned
As someone who has published dozens of games on xbox360 and steam but never had a huge success (360 I had a games with 100,000 downloads, and on steam as many as 5k sales for a single game), this is the kind of content I need to help understand how commercial developers think about the little things that take your game to the next level. Thank you!🎉
4:15 using lerp without a fixed starting point, will make it never reach the actual end-value. either store your start values before the while loop or use MoveTowards or something like that 5:35 instead of right-click > quick actions you should also be able to just hit [alt]+[return] 5:55 null it only if the current selected value is the current object. 7:20 singleton is really unnecessary here since you know you will have a parent/child relationship between the objects anyways. so you're just polluting the project with a unnecessary singleton, with all the drawbacks they have. 10:50 if(! Mathf.Approximately(InputManager.instance.NavigationInput, 0)) { HandleNextCardSelection(Mathf.Sign(InputManager.instance.NavigationInput)); } would be a more compact version of the update method that does the same I guess that you need to wait a frame, because the children are not always setup yet, when the code goes through this.
UI is it's own beast especially when you start adding gamepad support lol. Now I know no one reading this knows me but I'm gonna share this here anyway, I've had to go through these same struggles with my projects and I've had to create my own solutions for them, and I'm extremely proud to be able to say that I've been able to overcome these difficulties without the need of any video tutorials, hell even a year ago I wouldn't even know where to start with this lol.
@triplezgames3882
8 ай бұрын
Nice, good job
im just getting into coding and damn man the way your just throwing this code together is wild.
I saved this video for future reference, which is not something I do very often. I learnt something today - this was a really awesome video. Thank you and great work.
As always, great video! Thanks a lot. I was preparing the ui for a small project, and the video has made me rethink some things which I hadn't forgotten to keep in mind. Thanks, so helpful.
Overall great stuff! You could use the new Input System to detect when a controller takes control of the input to reselect the last selected object by using the OnControlsChanged method in your Input Manager or another component that is in the same component of the Player Input. You could also use the Selectable navigation system on the button component so you don't need to manually control the selected button when pressing the directions (the arrows at 1:43 in the scene view show how the navigation would be).
Video couldn't have come at a better time. We were just about to start adding menus and UI to our prototype. We really want to support gamepads and kbm from the start, thanks for this!
literally getting back into unity and this was exactly what i needed, thanks man.
Wow! This is the best tutorial in its category! Thanks, so helpful. Oh, and great channel, btw!
19 seconds in the video I already liked and followed you. Just that one sentence resonated so hard :,D
If you'd like to do everything he did but in a must faster, more efficient way, look into a tweening library. It gives you so many tools to make animations for both UI and objects. Once you get familiar with a tweening library and you understand how it works, it's benefit really starts to shine through
The quality of this tutorials is astonishing
Fantastic tutorial. Fast paced but easily understandable. Thank you!
You just earned yourself a new sub. Really liked the video. Keep up the good work.
Wow I've been waiting for that video for years !
Superbly done Brandon!
I was actually trying to solve this same problem for my game UI. I eventually deleted mouse navigation because I don't need it for gameplay but this tutorial might be very helpful for a future project. Thanks a lot.
Great tutorial and to the point, thank you!
Great tutorial, subscribed!
Excellent info. Thank you!
Thanks for the great tutorial! I was just implementing something similar in a project I'm working on and my solution was very sloppy. Looking forward to trying it this way!
Nice work sir, please keep keeping on!
Mind blowing!!! awesome content to say the least
your race condition is based on script execution order + Awake. Since OnEnable is also called when Awake is invoked, if your script executes before EventSystem's Awake is invoked, then your script will crash. A simple way around this I've found is just setting a flag in your script that gets set to true on awake, and short circuit OnEnable if that flag isn't met. It's technically safer and more correct than using a coroutine to wait one frame, though it accomplishes the same thing
Awesome tutorial :)!
awesome tutorial!
Really awesome content.
Great video!
Your videos are really helpful bro! +1 sub
This is quality stuff. After years of watching tutorials and even having a degree in Computer Science, I can confidently say this is the sort of thing every dev should learn and many of these programming concepts are being put into our upcoming project No Time Left
OMG, more like this please!
@sasquatchbgames
11 ай бұрын
Glad you liked it!
Good stuff!
i've been loving these "like a commercial game" tutorials, but i have a question, why would you replace the navigation controls of the default input with your own?
Nice video! Is it only me that if your mouse is still hovering over a card that it stays highlighted but the selection of an other card does happen?
This is really good, even for a professional mobile game dev :P
Sweet!
I hate to say it, but I think there is a huge difference in which kind of quality one would typically be aiming for. For example: is it AAA, or is it stylized? Is it indie dev or a huge team? The code is without debate, but this core situation is about everyone doing nothing good for UI. Hell, even I struggle. It is just so difficult to make UI look good when you can definitely make UI functional.
can you do like that all card are overlap each other and when we move pointer on card it will select as you did but will be in front like slay the spire
Hi. I have an issue where the UI seems to glitch and just continuously repeat the animation when hovering over it
The waiting for one frame thing could be because of script execution order?
I feel like there must be another way than reimplementing navigation "manually" in Update. I'm almost sure there's some callback when unity switches control from the mouse to keyboard/gamepad, and we could somehow intercept the event and set EventSystem.current.SetSelectedGameObject() before that event is handled?
@sealsharp
11 ай бұрын
It can be made simpler, if it is okay that the ui-object stays selected. I made myself a "UiKeepControlSelected" script that keeps a ui-object in menu selected when using the mouse on a scrollbar, because mouseover and scrolling deselects the prev. object but does not select a new one. private void Update() { if (EventSystem.current.currentSelectedGameObject == null) { if (this.lastSelected != null) { EventSystem.current.SetSelectedGameObject(this.lastSelected); } } else { this.lastSelected = this.eventSystem.currentSelectedGameObject; } }
Good vid, but using Update instead of a Coroutine is more performant if you have many btn elements. Something to keep in mind.
I really hope you follow up on this tut. I want to make a card game in unity and really need some more help.
Can we attach this script to our canvas instead of the cards?
you really type that fast? daym!
@Chris-lw5po
2 ай бұрын
No. It is sped up and you can hear it by the pitch of the keyboard clicks.
Can you please make a tutorial on “new input system” And how to use it properly like in commercial game. I tried multiple times to digest it, but with no effect. These docs are very vage and tutorials are as you said, suitable only for game jam type of games, but in this case easier to stick with the old one
Awesome video but if we use class inheritance that will be more appropriate.
3:00 Coroutines are your friend 😂
This does not appear to work if the element being animated is on any layout group. It will just move to the bottom left corner and then behaves fine after that but in the wrong location. And each UI element will then stack on top of each other. This is fine if the element is not in a layout group.
can we achieve same by using unity new UI Toolkit
Awesome tutorial, really nice! Ps: am I the only one that is mildly annoyed that people use startPos, and not position, but don't use startSca instead of startScale? Might be my perfectionism haha
@TheOriginalDuckley
11 ай бұрын
To me it seems like pos is more obviously referring to position but sca isn’t as obvious immediately that it is referring to scale?
@sasquatchbgames
11 ай бұрын
Lol! I'm sure you aren't the only one. Doesn't bother me though :D
My VsCode doesnt show the error when the interface methods are not implemented. kinda annoying
Why do we need the empty game object?
Hey, thats some high quality tutorial. I have a question though: When I got multiple elements which listen to the same event, how do you manage, which script should handle the event? Example: the three cards get selected with the arrow keys but the game camera moves with the arrow keys too.
@sasquatchbgames
10 ай бұрын
Guess that depends on the situation. You could have a gameState manager that will trigger certain events based on what 'state' your game is in for more complex things. For the simpler example you gave, since I would consider scrolling through cards UI - I would split my controls into 2 action maps, 1 being the game, 2 being the UI. You can disable the game controls and enable the UI controls whenever dealing with UI
Hi I am a software engineer in college for IT but I want to also learn game development but I do not not where to start i want to learn python for apps and softwares and C# for games and pc softwares as well I want to start with C# first because i know python is easy and not hard to learn if you know a language already but I want to learn C# for game development and software apps I wanted to know if anyone knew any update courses or tutorials for beginners I do software engineering and also want to do indie game development solo i know that’s hard but I want to try it I really want to be a software engineer and a indie game developer but I don’t know where to start with game design or programming
@sasquatchbgames
11 ай бұрын
If you want to use Unity/C# for game development, Check out Codemonkey's channel. He has a 10 hour free course aimed at beginners (it's one video) and I've heard nothing but great things about it
why not just use dotween for the animations instead of doing lerps etc, much easier lol tf
@danielj6417
3 күн бұрын
Often times Unity tutorials don't use plugins to keep things simple. I'm sure Dotween would work great
First
"Handle UI Like a Commercial Game " is pretty bald statement coming from "Me and my wife studio". No offense.
@RGcrasyRG
3 ай бұрын
The actual content of the video is good though.
@felipezymor9970
Ай бұрын
If he's making a commercial game, it's an UI just like in a commercial game.