ไม่สามารถเล่นวิดีโอนี้
ขออภัยในความไม่สะดวก
EASY Drag and Drop for UI - Unity Tutorial
ฝัง
- เผยแพร่เมื่อ 16 ส.ค. 2024
- ➡️➡️➡️UNITY BLACK FRIDAY SALE ⬅️⬅️⬅️
assetstore.uni...
⏱️ November 14 21:00 PT - December 4 23:59 PT ⏱️
📥 Get the Source Code 📥
/ 58469035
🤝 Support Me 🤝
Patreon: / samyg
Donate: ko-fi.com/samyam
►🔗 Relevant Video Links 🔗
ᐅ(PREVIOUS VIDEO) Easy Drag and Drop with Input System 2D | 3D - Unity Tutorial
• Easy Drag and Drop wit...
ᐅRectTransformUtility.ScreenPointToWorldPointInRectangle Unity Documentation
docs.unity3d.c...
ᐅInterface IDragHandler Documentation: docs.unity3d.c...
►Assets shown in this video:
ᐅGUI PRO Kit - Fantasy RPG:
assetstore.uni...
ᐅAlien Fantasy Forest: assetstore.uni...
ᐅOdin - Inspector and Serializer: assetstore.uni...
ᐅHQ FPS Weapons: assetstore.uni...
ᐅDreamteck Splines: assetstore.uni...
ᐅFirst person narrative adventures + complete puzzle engine: assetstore.uni...
ᐅNature Renderer: Personal License: assetstore.uni...
ᐅThe Vegetation Engine: assetstore.uni...
ᐅExpanse - Volumetric Skies, Clouds, and Atmospheres in HDRP: assetstore.uni...
ᐅFantastic City Generator: assetstore.uni...
ᐅRPG Character Mecanim Animation Pack: assetstore.uni...
ᐅPOLYGON Dungeon Realms - Low Poly 3D Art by Synty: assetstore.uni...
ᐅAnimancer Pro: assetstore.uni...
This video shows an easy built in way to drag and drop a UI object in Unity. You can also drag and drop a 2d collider and 3d collider object by adding the respective Physics Raycaster components to the camera, however the actual logic for correctly dragging and dropping a 3d object taking into account perspective is not covered in this video. For more information on that refer to my previous video ( • Easy Drag and Drop wit... ). We use the IDragHandler interface and implement it. We then convert our mouse position which is in screen coordinates to world coordinates with respect to the RectTransform.
►⏱️ Timestamps ⏱️
0:00 Intro
0:13 Sponsored Message
0:43 Scene Setup
1:51 Drag And Drop
7:20 IBeginDrag or IEndHandler
7:44 Physics Raycaster for Colliders
8:41 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...
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!
#madewithunity #gamedev #unity
➡️➡️➡️UNITY BLACK FRIDAY SALE ⬅️⬅️⬅️
assetstore.unity.com/?aid=1101ljAbS
⏱️ November 14 21:00 PT - December 4 23:59 PT ⏱️
This post contains affiliate links which we may receive a small commission ♥️
It's really good to see drag n drop on new input!
Nice when they make it easy. I've used drag and drop a fair amount in the past.
Coooooooool !! I've going to try this for creating a path on a map. I want a mini-map to come up (UI image of the map) then allow the player to drag a mouse or finger across it to create a path for something to follow. I bet this would work great for that.
What an easy way to make such a complex system (worked on it a couple of times from scratch)
The weirdest thing about it is that it recognized objects without them having any colliders.
You never stop being awesome do ya?
😄 Thank you!! Recognizes UI objects automatically, but needs extra steps (colliders + raycaster component on camera) for non UI objects
Hey, could you make a video about 2D aiming with a mouse and a gamepad with the input system? I'm having issues with jittery aiming with my implementation. Thanks!
@samyam Why do you need to transfer your screen coordinates to world coordinates if you are just moving something within the UI? It seems unnecessary for UI. Is this just copy+paste from the Unity docs, or do you understand this, and there is a good reason?
Thank for your awesome video.
For me on dragging, I was able to move UI outside the screen which was not expected.
I added custom logic to detect globalMousePosition and checked it against screen size.
Can you please do a video on anchor positions and how to convert one anchor position to another or to global etc
Thank you! :)
and how to keep element within the bounds of the canvas ?? any code example ?? thanks!
For me on dragging, I was able to move UI outside the screen which was not expected. I added custom logic to detect globalMousePosition and checked it against screen size.
Beware of Anchor Positioning
Nice Tutorial. I have a Problem with the Endposition of the UI-Element. On end draging the Elemt is not under the Mouse. Know anyone the solution
Thanks!
The problem is: are you really using the new input system if you rely on these "old" interfaces? Can it work with custom input? Controller for example
Technically yes you are using the new system, and the benefit is that you can then use the new system for all of the other input in your project. You can also make it work with controllers.
@@samyam yes I researched a bit better how it works and you are right, basically any input you bind to UI/Click is valid to start a drag event, thanks for the answer
I am waiting for your Next UE5 live stream
Yes! I’ve just been really busy 😵💫
Thank you for this tutorial. All this is fine as long as it's only the UI in the scene. Try to put this on a 3D game with a player where you use the new Input system for controls. Then the UI inputs simply do not work. No button presses etc. No one does a tutorial with a complex scene. If you can do these UI controls plus a simple 3D game and show how both the UI and the player controls work side but side in the same scene, you are a genius!
You just need to create 2 different action maps, one for player (to move in the game) and one for UI.
As soon as you need to switch to one or the other, you need to set the current schema accordingly.
That way the new input system recognize what you are trying to do.
@@alessandroricci8720 HAve you actually done this or are you saying what Unity and everybody else says cause in reality it doesn't work unless you use both input systems and also starts the scene without the player and then initiate the player by code. I tried using two action maps but the UI buttons DO NOT work. I can't share the project as it a is a release.
@@diliupg I'm developing right now a 2d platformer and i'm using it. When the player open inventory, or access teminal, i'll just switch between the 2 action maps.
And it's also work with gamepad.
Was not easy to make it working, but is feasible.
No matter how many tutorials I follow, these Drag Interfaces just don't work. Unity is such a mess. :(
As a workaround you can do it manually
th-cam.com/video/HfqRKy5oFDQ/w-d-xo.html
I included a section on what you would do if you want to use it with UI
Mam please make video enter and exit button for car for android phone in unreal engine 4
👍😎
1st