How to Enable UI with the New Input System
Вставка
- Опубліковано 1 сер 2024
- In this video I'll show you how to enable the new input system to work with the Unity UI, along with another cool input system feature!
ᐅGet the full Source Code Bundle to my Unity Tutorials 🤓
sam-yam.itch.io/samyam-full-s...
😎 Cool Unity Assets 😎
ᐅPeek - Editor Toolkit: assetstore.unity.com/packages...
ᐅEditor Console Pro: assetstore.unity.com/packages...
ᐅRainbow Folders 2: assetstore.unity.com/packages...
🤝 Support Me 🤝
Patreon: / samyg
Donate: ko-fi.com/samyam
►Timestamps
0:00 Intro
0:19 Event System
0:50 UI Actions
1:58 Types of Input
2:54 On Screen Stick and Button
5:37 Outro
💖💖THANK YOU TO ALL MY PATRONS 💖💖
❯❯❯ My Links ❮❮❮
💗 Patreon 💗
/ samyg
💬 Discord Server 💬
/ discord
🐦 Twitter 🐦
/ samyam_utube
📚 Facebook 📚
/ samyam.youtube
🎵 Music 🎵
Ambient Gold
streambeats.com
👍 Like and Subscribe! 👍
🖥️ Computer Setup 🖥️
*As an Amazon Associate I earn from qualifying purchases.
www.amazon.com/shop/samyam
Disclosure: This post may contain affiliate links, which means we may receive a commission if you click a link and purchase something that we have recommended. While clicking these links won't cost you any money, they will help me fund my development projects while recommending great assets!
#unitytutorial #unity #gamedev - Навчання та стиль
I love your enthusiasm for the input system, everyone should be using it by default - it's amazing!
Just a heads up, if you modify the default input asset for the ui, make sure to save the asset into your project. The default input asset will revert to defaults next time you launch the editor because it's part of the package (packages are meant to be read only)
Great tip!
until it is working. Old system was much more intuitive
mine doesn't even have default input asset to begin with. the whole thing is now hopelessly unresponsive
Your videos on input system and cinemachine are a life saver! Thank you for making my learning journey more fun and feasible!
Thank you ! The On-Screen Button and On-Screen Stick part just made my day!
Great content, straight to the point and very clear!
your videos are legitimately great. informative, to the point, detailed examples and use cases. easiest follow ever, thanks so much
Thank you!! 😋
THANK YOU. You have no idea how long I searched the Unity forums trying to figure out why I didn't have the option to update my Input Module to the new version (didn't have the package installed)
I was looking for something just like this, yesterday.
Thanks!!
Thanks so much - I was scratching my head on this one!
Awesome and simple tutorial. Thank you 🙏
I love how detailed these titles are
Switching to new input system step by step ...thanks samyam
Nice as always👍🏻
Very helpful, thank you so much!
Fixed my issue in the first minute, thanks
thank you so much ive been looking for this for days. happy new year!
Happy New Years! 🎉
I just want to say: I love your videos
terrific tutorial, so useful!
Another great video!!
Thank you so much!!
Many thx. simple click solved all my issues :)
Very Helpful
Thanks you, it's helped a lot
Thanks for this, I may actually switch to the new system after watching this video.
🎉
Cool, thanks!
Thanks You So Much!!
You Help me!
I made sure to click the Like-"budden" as a thank you for this excellent tutorial! ;D Now I gotta go configure all the "buddens" in my game!
Lifesaver. Thank you.
Omg thank you!!
Awesome! Now I want to make a mobile game!
Great video as usual.
You are great. Thanks so much for your help. :)
Thank you :)
SAMYAMMMMM i love your tips...... !!!! i am jumping happy
Thank u ☺️
Great Tuterial
Sweet! It would have been really nice if you managed to just show how those actions move an object, just to show what exactly needs to be imported in order to make it work!
YEEEE thank you fixed my issue
Thank you so much
Buddon! 👍💕
Really helpful video thank you, I got the button to register in the input debugger as the 'A' Keyboard key however it does not do to my object what the 'A' button does on my keyboard am I missing a step where I link the on screen button to my object or do I need to change my code ? thank you in advance
Thank you so much Samyam-paai!🥺 Next Brackeys?👌
The next samyam 😉
@@samyam Even better🤩
but how do i make use of the button in my game ? like we used to do before input.getAxis("Horizontal") , where do i get this ?
I even didn't know Unity had a new Input system so thanks so much for this tutorial.
Yeah! All of my videos use the newer system 😄
@@samyam But already had a problem. I install it in a game which I was making but the console says this " You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Setting". How can I fix it?
That means somewhere in your code or some script is using the old input system. If you want to use both you can change the Active Player Input Handling in the Player Settings to Both, but I recommend finding where the old system is being used and overriding it
@@samyam I know where it but I don't know how to change it
Code: float _horizontalInput = Input.GetAxisRaw("Horizontal");
Here’s my tutorial on how to use the new system:
ua-cam.com/video/yRI44aYLDQs/v-deo.html
Спасибо!
Cant believe nothing helped to solve this issue except for your video
Is there a special way to have submenus? Do I just need to have a script to select the first option on the new menu?
🙏PLEASE ANSWER🙏
How to trigger the onScreen event inside the OnClick() function ? THANKS !
Question: does any of these new changes affect things like IPointerEnterHandler extension? for things like drag/drop, Onpointerdown/enter methods that comes with the extension.
No it shouldn't impact the IPointerEnterHandler extension or the Onpointerdown
You literally saved my life. My UI buttons weren't working at all with the new input system but watching this solved it within the first 2 minutes. THANKYOU!
why does my UI dont register the gamepad and keyboard inputs ? lets say im the main menu and only the pointer and the click of the button work , waddaheeeeelll
I'm making a party game for 2-4 players and I want each one of them to control their own "select character" UI menu.
For that, I'm using a Multiplayer Event System, but it doesn't let me use DefaultInputActions...
Do I have to create my own InputActions to make it work?
My most recent video covers this! :)
ua-cam.com/video/81GecyuNapg/v-deo.html
How to make a navigation between ui elements work?? Ive set up navigation on button component but with new a new Input system it's just don't want to move to another button.
I have a video on navigation:
ua-cam.com/video/Hn804Wgr3KE/v-deo.html
great tutorial, can you pls make a tutorial on ui toolkit integrated with the new input system? There are not any good tutorials or examples that seem to bring those two concepts together.
It's on my list!
how did you get input system 1.0.2? my only options are for 0.2 and lower
There should be an option to see other versions in the package manager. You can also join our Discord and ask in the help chat for further help (and post an image of the issue)
Great video. How can I make it so the gamepad (left stick) moves the cursor around?
You can override the cursor position:
Mouse.current.WarpCursorPosition(new Vector2(123, 234));
and put in for the vector the current position of the gamepad location.
for the gamepad location maybe you start the pointer at the center of the screen and move it with the joystick delta.
I have 7 image buttons on my screen, how do i know which one was clicked?
You can have a script implement the IPointerClickHandler to tell what image is being clicked. Or your button has an OnClick method which you can implement in another script and keep track of which button has been pressed.
forum.unity.com/threads/eventsystem-vs-new-input-system.850840/
I just came across your channel and these videos are amazing! The problem I still have with migrating is the .isPressed functionality I get from InControl. Do you have videos that cover this?
What do you mean InControl? Is that an asset pack? Unfortunately I do not have experience with that asset pack. If you are using an on screen button you can read the value it is piping to.
@@samyam Yes, InControl is an asset. All I'm trying to do with the new input system is to be able to detect when a button is pressed. In InControl, the functionality is like this: "if(JumpButton.isPressed) { do something }. If I can replicate that in the new input system, then I'll most likely convert to it since your videos make it look so much easier than what I have to do with InControl
If you want to check if a UI button is pressed this should work with the Event System, the new Input System UI just swaps the control input and processing to use the new system
Here are some possible ways:
answers.unity.com/questions/921720/how-can-i-check-if-a-ui-button-is-selected.html
If i were creating my own action asset/ input system, how would i call some of these functionalities in the UI!
If you want to override the UI Input Action values you can create your own input action and input it in the Input System UI module. If you want to use the current action map as a base you can copy it as I show here ua-cam.com/video/81GecyuNapg/v-deo.html around 4:56. If you want to just call gameplay functionality from the UI it’s the same as the old system, for example the button component has an on click event that can call different scripts functions. I hope that helped, let me know if you need any clarification.
@Sam - Great video. As clear as always thanks.
@EveryoneElse - Become a patreon, it's worth it to help support this channel :)
Thanks so much!! Your videos are awesome as well 😁
Im trying to make a default input action that I can use between games but it seems like If I use the the event system with a pure copy/paste of the UI action map from the default over to my custom, it just does nothing. I also matched the control scheme. Do you know what im doing wrong? If I have to use the default, I believe that means if I need to make edits, I wont be able to in the future.
This is ONLY a problem on the event system with the ui. I have no probelms activating my other action amps built into the input action I made.
Did you make sure to copy the control schemes in the default input action asset?
@@samyam I did. It didnt seem to help. I did not copy over all the control schemes because I didnt need joystick or xr but I copied everything else and went through each action and assigned the scheme just like the default. Even the mouse doesnt work on the menu when I do this.
I am away from my computer but when I get back, I will try creating an input action from scratch. Im thinking because I copied it over from a previous project, there is a broken reference or something that isnt as visible when it comes to the event system.
Until I fugure it out, ill probably rely on the default one for ui - I was just being a bit progressive by trying to solve the problem before I needed a custom one.
Excellent tutorials your channel has been very useful for getting touch controls working with the new Input System.
I've run into a problem with the On-Screen buttons: I want a button that disables itself and opens a menu when pressed, but the input system is throwing a bunch of errors, I'm guessing it's missing some kind of callback because the button becomes disabled, any suggestions?
Thanks! What kind of errors is it throwing to get a better idea?
This is a guess, but you can also disable a control, action.Disable()
@@samyam
The trouble is that I don't want to disable the action. I want to be able to press the start button on the controller 'Button:/Gamepad/start' to pause the game and bring up the menu while hiding the on-screen button. But the game also supports touch controls (hence the on-screen button).
These seem to be the relevant error messages:
Control index out of range
UnityEngine.InputSystem.LowLevel.NativeInputRuntime/c__DisplayClass7_0:b__0 (UnityEngineInternal.Input.NativeInputUpdateType,UnityEngineInternal.Input.NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType,intptr)
Exception 'ArgumentNullException' thrown from state change monitor 'InputActionState' on 'Button:/Gamepad/start'
UnityEngine.InputSystem.LowLevel.NativeInputRuntime/c__DisplayClass7_0:b__0 (UnityEngineInternal.Input.NativeInputUpdateType,UnityEngineInternal.Input.NativeInputEventBuffer*)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType,intptr)
It only works on PC, but not android . When I built to my android mobile, it can't move
I was so confused why when i click the buttons nothing happens i searched on youtube and its samyam ahah everything i search i find you lol thanks a lot you fixed my problem
😎👍
I actually have a VERY weird problem!
I just noticed that in my unity, in all scenes, I CANT ADD UI!!!
like, the entier section is not there when you left click the hierarchy.
Does anyone have any idea whats going on? (Yes. Its not there. im not blind)
Try restarting and if that doesn’t work try removing Unity UI and reinstalling in Window>Package Manager
forum.unity.com/threads/ui-not-showing-when-i-right-click-on-hierarchy.732977/
Seems to be a bug
Your actions asset already has a UI Action Map with dozens of things added. You don't cover how to get those or add them to an existing input action asset that doesn't have those. Also, how do you switch from PlayerInput using Player, to UI overriding input?
Yeah my project didnt had Default Input Action Asset
Great video! Very informative. Do you know how to disable multi-touch with this system? I can't get it to work...
Perhaps setting the Pointer Behaviour to Single Unified Pointer?
@@samyam Unfortunately not x_x Unity docs mention there not being a corresponding API either >.>
Thanks for the video! However, I am wondering how to press the UI object with the gamepad with the new input system?
You should be able to navigate the menu if an item is already selected with the gamepad. However if you want a gamepad cursor I have a video on that: ua-cam.com/video/Y3WNwl1ObC8/v-deo.html
@@samyam thank you so much! I'll be watching that later :D
nice video...
I am just wondering, I am currently fighting with touch zoom (pinch), which is working OVER the UI Buttons.. Were you already able to test this with the new input system ?
eventsystem.current.ispointerovergameobject -> were not able to get it to work with the new input system
thanks..
The new input system has a function for that implemented
public override bool IsPointerOverGameObject(int pointerOrTouchId)
docs.unity3d.com/Packages/com.unity.inputsystem@1.0/api/UnityEngine.InputSystem.UI.InputSystemUIInputModule.html
Are you trying to stop the pinch when it’s over the UI?
@@samyam yes, either pinch to zoom or 1 finger to rotate the camera arround the player, however, as soon as I use the buttons to move the player, the camera is somehow "moving". Thanks for the link to the InputSytem, I guess, I will try it out later after work. ;-)
Someone in the discord chat had a similar implementation @Metamax
pastebin.com/QqQY2B77
Maybe that helps!
@@samyam thanks for guiding me in the right direction.. I finally were able to make it work, but for everyone reading this I have to tips:
1) DON'T forget to activate the NEW Input System Event Manager (took me 2 hours to figure that out, still the old Event System was activated)
2) when you are using pinch to zoom, however also use buttons to navigate on a touch screen -> make a bigger invisible button under your navigation button, otherwise a bigger thumb might always touch outside your button by accident .. in my case it always started to rotate the camera
Oh I thought since you commented on this video you had it enabled 😂 But glad you fixed it!
Is this supports world space UI within a touch controlled mobile application?
Yeah the Input System module provides the same functionality as the original one
docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/UISupport.html
@@samyam Thank you
Your way of explaining is very good but I want more about ui like custom buttons and new screens on clicking buttons
Thanks! And great ideas!
Hello, great video, I have problem, maybe someone will help me. I have an UI, but I want to make it avoidable, like I can't select units through it and do other stuff in game, just react on UI, buttons. How to do it with new input system?
If you want a certain UI to be disabled you can go to the Image component of it and deselect Raycast Target.
@@samyam I didnt mean that. I will try explain that simplier :D I have some UI button and behind that I have some game object for example cube. When I click on UI button, also my game object behind it reacts, what I want to do is making that UI button not transparent. I can't make it using new input system
After I switched the Input System, the game is not working and saying that I have Switched the Input
You have to make sure that you are not using the old system anywhere if you want to fully switch to the new one
@@samyam how do I do that ???
Is there Something that I need to change. I am actually on the Unity FPS Microgame and I want to add a Joystick and some UI Buttons to it, but it is not Working, I tried many Tutorials and found you the same way, but I can't do it, it is just errors.
The UI input Action doesn't work alongside the Player Input Action. Why is that? You will be very smart to show a custom Player Input asset with Player and UI Input Actions working TOGETHER. There isn't a single tutorial by anyone on these controls working together through many forums have this problem highlighted, and none of the solutions work properly.
What do you mean? If your Input Action Asset has a UI map you can use that for the Event System, and also use another map for your movement. What exactly isn't working?
Will you teach about controller rumble ?
I have a video covering some of that here!
ua-cam.com/video/f0wax8LufqQ/v-deo.html
@@samyam Thank you so much.
isometric movement tutorial pls
I have a video on mouse click movement here
ua-cam.com/video/b0AQg5ZTpac/v-deo.html
Hopefully more isometric videos coming in the future, I have a lot things I want to cover 🙂
@@samyam that's nice, thank uuuu
Now my buttons dont work
Thx! But where the code example?
Do you mean source code? There’s none for this video since I just pressed a button to switch to the new system 😅
@@samyam Okay thx anyway :)
UI doesn't appear for me
What do you mean? The canvas?
@@samyam I can't right-click in the hierarchy, so I use the "GameObject" window, but UI doesn't appear there. What can I do?
Seems to be a bug, maybe these forums might help
forum.unity.com/threads/ui-not-showing-when-i-right-click-on-hierarchy.732977/
forum.unity.com/threads/ui-menu-missing-from-create-context-menu.996434/
fuck that inro scared me
How can I use it with swipe from this ua-cam.com/video/XUx_QlJpd0M/v-deo.html ?
You don’t need to use the UI for swiping. Although in this video: ua-cam.com/video/YV5KOZHsIz4/v-deo.html
I did a trick a used the on screen joystick to simulate swiping on the screen
this system makes zero sense since if you're making a game you'll pretty much make your own input action map but then this UI NEEDS its own default action map in order to work. So when you go back to player input component it'll just tell you to sync the event system's map with player input map, causing you to lose all the UI map from default.
You can replace the default one with your own