ไม่สามารถเล่นวิดีโอนี้
ขออภัยในความไม่สะดวก

Handle UI Like a Commercial Game (Custom Animations + Different Control Schemes) | Unity Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ส.ค. 2024
  • Show your Support & Get Exclusive Benefits on Patreon (Including Access to this project's Source Files + Code) - / sasquatchbgames
    Join our Discord Community! - / discord
    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...
    ---
    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.uni...?aid=1100lwgBQ
    ---
    Unity Selectable Documentation:
    docs.unity3d.c...
    Unity Free Cards on the Asset Store
    assetstore.uni...
    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.steampow...
    Wishlist Samurado!
    store.steampow...
    Don't forget to Subscribe for NEW game dev videos every Monday & Thursday!
    Follow us on Twitter for regular updates!
    / sasquatchbgames
    #unitytutorial #unity2d #unity3d

ความคิดเห็น • 78

  • @Astrouia
    @Astrouia ปีที่แล้ว +114

    YES! please make a series called (Like a Commercial Game) THIS IS SOOO HELPFUL!

  • @Soraphis91
    @Soraphis91 ปีที่แล้ว +27

    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.

  • @legendaryswordsman2279
    @legendaryswordsman2279 ปีที่แล้ว +16

    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.

  • @DiabloGoldSecrets
    @DiabloGoldSecrets 3 หลายเดือนก่อน +2

    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!🎉

  • @GamingJadenWilliams
    @GamingJadenWilliams 5 หลายเดือนก่อน +1

    Fantastic tutorial. Fast paced but easily understandable. Thank you!

  • @NoTimeLeft_
    @NoTimeLeft_ ปีที่แล้ว +8

    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

  • @vazzius
    @vazzius ปีที่แล้ว +13

    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).

  • @realprodigious
    @realprodigious 3 หลายเดือนก่อน

    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

  • @caradepeido
    @caradepeido หลายเดือนก่อน

    Such a refreshing video in the unity tutorial space of youtube! I find that a majority of the videos are made by unity/programming hobbyists and therefore disregard basic coding principles and background knowledge that you displayed here :) thank you

  • @Keywarn
    @Keywarn ปีที่แล้ว +3

    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!

  • @stropheum
    @stropheum 6 หลายเดือนก่อน +1

    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

  • @marularch
    @marularch ปีที่แล้ว +1

    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.

  • @chrispollard2898
    @chrispollard2898 3 หลายเดือนก่อน

    im just getting into coding and damn man the way your just throwing this code together is wild.

    • @sakeb1
      @sakeb1 2 หลายเดือนก่อน +1

      yeah he is super fast, comes with experience

  • @BarcelonaMove
    @BarcelonaMove 3 หลายเดือนก่อน

    The quality of this tutorials is astonishing

  • @MiniatureGiantsGameDev
    @MiniatureGiantsGameDev ปีที่แล้ว +2

    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.

  • @shi_503
    @shi_503 11 หลายเดือนก่อน +2

    literally getting back into unity and this was exactly what i needed, thanks man.

  • @udadni
    @udadni 6 หลายเดือนก่อน

    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!

  • @-Engineering01-
    @-Engineering01- ปีที่แล้ว +1

    Wow I've been waiting for that video for years !

  • @KolmeGurua
    @KolmeGurua 4 หลายเดือนก่อน

    19 seconds in the video I already liked and followed you. Just that one sentence resonated so hard :,D

  • @melpermo
    @melpermo ปีที่แล้ว

    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.

  • @kimen1
    @kimen1 ปีที่แล้ว +1

    Wow! This is the best tutorial in its category!
    Thanks, so helpful. Oh, and great channel, btw!

  • @Indolen_s
    @Indolen_s 2 หลายเดือนก่อน

    This is great video!

  • @radiance_37k
    @radiance_37k ปีที่แล้ว

    You just earned yourself a new sub. Really liked the video.
    Keep up the good work.

  • @SurfBit
    @SurfBit ปีที่แล้ว

    Your videos are really helpful bro! +1 sub

  • @globes179
    @globes179 7 หลายเดือนก่อน

    Nice work sir, please keep keeping on!

  • @Thesupperals
    @Thesupperals 9 หลายเดือนก่อน +1

    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.

  • @DanPos
    @DanPos ปีที่แล้ว

    Awesome tutorial :)!

  • @midniteoilsoftware
    @midniteoilsoftware ปีที่แล้ว

    Superbly done Brandon!

  • @fatabi95
    @fatabi95 หลายเดือนก่อน

    Amazing thanks a lot !

  • @regys9521
    @regys9521 10 หลายเดือนก่อน

    Mind blowing!!! awesome content to say the least

  • @snooksv3172
    @snooksv3172 6 หลายเดือนก่อน

    Good vid, but using Update instead of a Coroutine is more performant if you have many btn elements. Something to keep in mind.

  • @pocket-logic1154
    @pocket-logic1154 ปีที่แล้ว

    Excellent info. Thank you!

  • @Lazzarus7
    @Lazzarus7 ปีที่แล้ว

    Great tutorial and to the point, thank you!

  • @tientam779
    @tientam779 ปีที่แล้ว

    Great tutorial, subscribed!

  • @dunkeshon2309
    @dunkeshon2309 4 หลายเดือนก่อน

    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

  • @tianqigao869
    @tianqigao869 ปีที่แล้ว

    awesome tutorial!

  • @BrandonNyman
    @BrandonNyman 10 หลายเดือนก่อน +1

    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.

  • @Xiimo_
    @Xiimo_ ปีที่แล้ว +1

    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?

  • @GBSCronoo
    @GBSCronoo ปีที่แล้ว

    OMG, more like this please!

  • @zacharysilverzweig7715
    @zacharysilverzweig7715 ปีที่แล้ว

    Really awesome content.

  • @masoncrowe
    @masoncrowe ปีที่แล้ว

    Great video!

  • @kardrasa
    @kardrasa ปีที่แล้ว

    you really type that fast? daym!

    • @Chris-lw5po
      @Chris-lw5po 5 หลายเดือนก่อน

      No. It is sped up and you can hear it by the pitch of the keyboard clicks.

  • @grzesfu
    @grzesfu ปีที่แล้ว +1

    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
      @sealsharp ปีที่แล้ว +2

      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;
      }
      }

  • @sajadtroll9186
    @sajadtroll9186 ปีที่แล้ว

    3:00 Coroutines are your friend 😂

  • @viraj3944
    @viraj3944 5 หลายเดือนก่อน +1

    Can we attach this script to our canvas instead of the cards?

  • @nickjunes
    @nickjunes 13 วันที่ผ่านมา

    Ok but what is this 'f' unit type and what are these variable types "SerializeField" and "Range" and how can you have 2 variable types for one variable?

  • @MacMiggity
    @MacMiggity ปีที่แล้ว

    This is really good, even for a professional mobile game dev :P

  • @iiropeltonen
    @iiropeltonen ปีที่แล้ว

    Good stuff!

  • @ezekielswiss4347
    @ezekielswiss4347 10 หลายเดือนก่อน

    I really hope you follow up on this tut. I want to make a card game in unity and really need some more help.

  • @johnsummers101
    @johnsummers101 2 หลายเดือนก่อน

    So, I get the concept of singleton. but what actually makes it that? The code looks the exact same.

  • @bananaboyTS
    @bananaboyTS 9 หลายเดือนก่อน

    My VsCode doesnt show the error when the interface methods are not implemented. kinda annoying

  • @MrDarshan2714
    @MrDarshan2714 ปีที่แล้ว

    Awesome video but if we use class inheritance that will be more appropriate.

  • @TheCamiCono
    @TheCamiCono ปีที่แล้ว

    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?

  • @viraj3944
    @viraj3944 5 หลายเดือนก่อน

    Why do we need the empty game object?

  • @user-jn3of9wb8q
    @user-jn3of9wb8q 11 หลายเดือนก่อน

    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

  • @weks
    @weks ปีที่แล้ว

    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
      @TheOriginalDuckley ปีที่แล้ว

      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
      @sasquatchbgames  ปีที่แล้ว +2

      Lol! I'm sure you aren't the only one. Doesn't bother me though :D

  • @mohitKumar-lo5gm
    @mohitKumar-lo5gm 3 หลายเดือนก่อน

    can we achieve
    same by using unity new UI Toolkit

  • @sealsharp
    @sealsharp ปีที่แล้ว

    Sweet!

  • @afabulouswhale
    @afabulouswhale ปีที่แล้ว

    Hi. I have an issue where the UI seems to glitch and just continuously repeat the animation when hovering over it

  • @zeon137
    @zeon137 ปีที่แล้ว

    The waiting for one frame thing could be because of script execution order?

  • @opxv
    @opxv ปีที่แล้ว

    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
      @sasquatchbgames  ปีที่แล้ว

      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

  • @ecenjoyer
    @ecenjoyer 8 หลายเดือนก่อน +1

    why not just use dotween for the animations instead of doing lerps etc, much easier lol tf

    • @danielj6417
      @danielj6417 3 หลายเดือนก่อน

      Often times Unity tutorials don't use plugins to keep things simple. I'm sure Dotween would work great

  • @Cookinbk
    @Cookinbk ปีที่แล้ว

    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
      @sasquatchbgames  ปีที่แล้ว +2

      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

  • @Coco-gg5vp
    @Coco-gg5vp ปีที่แล้ว

    First

  • @RGcrasyRG
    @RGcrasyRG 6 หลายเดือนก่อน

    "Handle UI Like a Commercial Game " is pretty bald statement coming from "Me and my wife studio".
    No offense.

    • @RGcrasyRG
      @RGcrasyRG 6 หลายเดือนก่อน

      The actual content of the video is good though.

    • @felipezymor9970
      @felipezymor9970 4 หลายเดือนก่อน

      If he's making a commercial game, it's an UI just like in a commercial game.