Gamepad Cursor with Input System - Unity Tutorial
samyam
Make a custom gamepad cursor using Unity's New Input System. This way you can navigate UI using a controller similar to a mouse.
๐ฅ Get the Source Code ๐ฅ https://www.patreon.com/posts/57282387
๐ค Support Me ๐ค Patreon: https://www.patreon.com/samyg Donate: https://ko-fi.com/samyam
Thanks GeekZebra for helping make this video possible! *Sorry for the desk noises, the mic is really sensitive and setting the controller up and down is not helping.
โบ๐ Relevant Video Links ๐ แ Virtual Mouse Input System Documentation https://docs.unity3d.com/Packages/com.unity.inputsystem@1.1/api/UnityEngine.InputSystem.UI.VirtualMouseInput.html แ Kenney - Crosshair Pack https://www.kenney.nl/assets/crosshair-pack
In this video I show you how to make a gamepad virtual mouse cursor that can navigate around the scene and interact with the UI. This works with the new input system, any canvas scale and canvas type, the PlayerInput component, and you can adapt it further to fit your needs easily.
We use a gamepad or controller and pipe the input to a Virtual Mouse in the Input System. In our Input Action Asset UI map (created from the PlayerInput component), we add actions for the position and click of the Virtual Mouse. That input action asset is used in the Event System to replace the system mouse values.
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!
๐ Other Cool Unity Assets ๐ แ Peek - Editor Toolkit: https://assetstore.unity.com/packages/tools/utilities/peek-editor-toolkit-149410 แ Editor Console Pro: https://assetstore.unity.com/packages/tools/utilities/editor-console-pro-11889 แ Rainbow Folders 2: https://assetstore.unity.com/packages/tools/utilities/rainbow-folders-2-143526
โบโฑ๏ธ Timestamps โฑ๏ธ 0:00 Intro 0:38 Install Input System 1:07 Gamepad Cursor Samples 1:57 Set up Scene 2:44 Create Cursor UI Image 4:27 Gamepad Cursor Script 19:51 PlayerInput and Input Action Asset 22:46 Debugging & Fixes 24:38 Preview working 25:40 Add Cursor Padding 26:40 OnControlsChanged Switching Between Mouse & Gamepad 33:28 Quick Null Reference Errors Fix 33:55 ScrollView Preview 34:18 Outro
๐๐THANK YOU TO ALL MY PATRONS ๐๐
โฏโฏโฏ My Links โฎโฎโฎ ๐ Patreon ๐ https://www.patreon.com/samyg ๐ฌ Discord Server ๐ฌ https://discord.gg/SwCKB3Q ๐ฆ Twitter ๐ฆ https://twitter.com/samyam_utube ๐ Facebook ๐ https://www.facebook.com/samyam.youtube/ ๐ต Music ๐ต Ambient Gold streambeats.com ๐ Like and Subscribe! ๐
๐ฅ๏ธ Computer Setup ๐ฅ๏ธ *As an Amazon Associate I e ... https://www.youtube.com/watch?v=Y3WNwl1ObC8
183266010 Bytes