EASY Drag and Drop for UI - Unity Tutorial

Поділитися
Вставка
  • Опубліковано 26 лип 2024
  • ➡️➡️➡️UNITY BLACK FRIDAY SALE ⬅️⬅️⬅️
    assetstore.unity.com/?aid=110...
    ⏱️ 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.com/ScriptRefere...
    ᐅInterface IDragHandler Documentation: docs.unity3d.com/Packages/com...
    ►Assets shown in this video:
    ᐅGUI PRO Kit - Fantasy RPG:
    assetstore.unity.com/packages...
    ᐅAlien Fantasy Forest: assetstore.unity.com/packages...
    ᐅOdin - Inspector and Serializer: assetstore.unity.com/packages...
    ᐅHQ FPS Weapons: assetstore.unity.com/packages...
    ᐅDreamteck Splines: assetstore.unity.com/packages...
    ᐅFirst person narrative adventures + complete puzzle engine: assetstore.unity.com/packages...
    ᐅNature Renderer: Personal License: assetstore.unity.com/packages...
    ᐅThe Vegetation Engine: assetstore.unity.com/packages...
    ᐅExpanse - Volumetric Skies, Clouds, and Atmospheres in HDRP: assetstore.unity.com/packages...
    ᐅFantastic City Generator: assetstore.unity.com/packages...
    ᐅRPG Character Mecanim Animation Pack: assetstore.unity.com/packages...
    ᐅPOLYGON Dungeon Realms - Low Poly 3D Art by Synty: assetstore.unity.com/packages...
    ᐅAnimancer Pro: assetstore.unity.com/packages...
    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/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!
    #madewithunity #gamedev #unity
  • Наука та технологія

КОМЕНТАРІ • 28

  • @samyam
    @samyam  2 роки тому

    ➡️➡️➡️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 ♥️

  • @TheKr0ckeR
    @TheKr0ckeR 2 роки тому +2

    It's really good to see drag n drop on new input!

  • @ClassicGameSessions
    @ClassicGameSessions 2 роки тому +2

    Nice when they make it easy. I've used drag and drop a fair amount in the past.

  • @ooDEFENDERoo
    @ooDEFENDERoo 2 роки тому +1

    Thank you! :)

  • @kyleme9697
    @kyleme9697 2 роки тому +1

    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.

  • @sashokcs
    @sashokcs Рік тому

    Thanks!

  • @krissloo143
    @krissloo143 2 роки тому +1

    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?

    • @samyam
      @samyam  2 роки тому +2

      😄 Thank you!! Recognizes UI objects automatically, but needs extra steps (colliders + raycaster component on camera) for non UI objects

  • @AlphaLul
    @AlphaLul 2 роки тому +1

    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!

  • @JetBlackJester
    @JetBlackJester Рік тому

    @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?

  • @kamyasuraj131
    @kamyasuraj131 Рік тому

    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

  • @andidroid6465
    @andidroid6465 2 роки тому

    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

  • @uzumakisasuke5539
    @uzumakisasuke5539 2 роки тому +1

    👍😎

  • @vishalnaruka4360
    @vishalnaruka4360 2 роки тому +1

    and how to keep element within the bounds of the canvas ?? any code example ?? thanks!

    • @kamyasuraj131
      @kamyasuraj131 Рік тому

      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

  • @deepakgiri.j1973
    @deepakgiri.j1973 2 роки тому +1

    I am waiting for your Next UE5 live stream

    • @samyam
      @samyam  2 роки тому +1

      Yes! I’ve just been really busy 😵‍💫

  • @zankaster3935
    @zankaster3935 2 роки тому

    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

    • @samyam
      @samyam  2 роки тому +1

      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.

    • @zankaster3935
      @zankaster3935 2 роки тому

      @@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

  • @zainuldin9095
    @zainuldin9095 2 роки тому +2

    1st

  • @diliupg
    @diliupg 2 роки тому

    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!

    • @alessandroricci8720
      @alessandroricci8720 2 роки тому

      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.

    • @diliupg
      @diliupg 2 роки тому

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

    • @alessandroricci8720
      @alessandroricci8720 2 роки тому

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

  • @siddharthpandey8532
    @siddharthpandey8532 2 роки тому

    Mam please make video enter and exit button for car for android phone in unreal engine 4

  • @Ayanami3rd
    @Ayanami3rd 2 роки тому

    No matter how many tutorials I follow, these Drag Interfaces just don't work. Unity is such a mess. :(

    • @samyam
      @samyam  2 роки тому

      As a workaround you can do it manually
      ua-cam.com/video/HfqRKy5oFDQ/v-deo.html
      I included a section on what you would do if you want to use it with UI