My Favorite way to Click on GameObjects

Поделиться
HTML-код
  • Опубликовано: 18 ноя 2024

Комментарии • 50

  • @Miss-ex1gnt
    @Miss-ex1gnt Год назад +22

    Do keep mindful of any objects that may block the raycast! I had a canvas with components that I animated out of my screen, but they kept on blocking the raycast. I added "deactivate raycast target" at the end of the animation and solved the "mystery". Still, I must admit, I have gone bonkers until I finally realized what it was! DX

    • @justcore69
      @justcore69 4 месяца назад

      Your comment just saved a lot of my gamejam time. Thank you!

  • @Roadtotarget
    @Roadtotarget Месяц назад +2

    Don't forget to add Box Collider component to your objects you want to click

  • @emilyhorton996
    @emilyhorton996 18 дней назад

    deserves way more views and thumbs ups. thank you so much!

  • @sissond
    @sissond 2 года назад +1

    I needed this like 11 months ago ;)
    Might go back and make that functionality more elegant

  • @prhc
    @prhc Год назад +3

    thanks for the video,
    when using this technique with UI toolkit in unity version 2021.3.24 i had the problem of not being able to select any game objects, only PanelSettings were being selected.
    i solved this by setting the picking mode of the root visual element to Ignore in the UI Builder

  • @sakeb1
    @sakeb1 6 месяцев назад +1

    3:47: go to definition, best thing I learned here woah

  • @danilocolassoo
    @danilocolassoo Год назад +1

    That's a really good Interactable objects approach!
    Specially combined with UnityEvent

    • @VRwithAndrew
      @VRwithAndrew  Год назад

      Thank you, and exactly! It's incredibly versatile.

  • @adfs774
    @adfs774 Год назад

    This is so much better than using annoying raycasting. Thx so much!!1

  • @clamarped
    @clamarped 9 дней назад

    Great video, however, I would have loved it if you had explained how it would work with different objects with different actions, as I can't really see that function with how you show it in the example sadly.

  • @ImKyleConway
    @ImKyleConway 4 месяца назад

    I've set up the script and it works great, however I am trying to use this to inspect items but when I adjusted the main camera's near clipping plane, it no longer worked. Anyone know why?

  • @zuban1988
    @zuban1988 Год назад +3

    Thank you!
    BTW, I had a problem with code generted mesh, it did not fire the events until you add collider (MeshCollider in my case), then it works.

    • @rd88ify
      @rd88ify 9 месяцев назад

      Thanks! This resolved my issue. In my case I had to add a Box collider to my 3D game object

    • @LetsFacetheMusicandDance
      @LetsFacetheMusicandDance 2 месяца назад

      I had the exact same problem ... wish I saw this comment sooner : )

  • @smirelesz
    @smirelesz Год назад

    Great video. Elegant solution. Thank you!

  • @martinjacobsen5974
    @martinjacobsen5974 3 месяца назад

    Yeah sorry. It's a super sweet video and very to the point. But as a beginner I have no idea what I'm looking at what is from unity and what you wrote ahead of time. I can see that it's a super straight forward system once it's set up but I needed the "setting it up from zero" Thanks for the video though.

  • @froggothecommentator8036
    @froggothecommentator8036 3 месяца назад

    sorry but im having some problem with the clicking system rn. It keeps telling me that im having the error "CS0246:the type of namespace name... could not be found". Could you help me with this please?

  • @ms.awesome
    @ms.awesome Год назад +1

    okay so im using Cursor.lockState = CursorLockMode.Locked; because my game is in first person but this prevents being able to click on the object like this! Any way to fix it or workaround it?

    • @VRwithAndrew
      @VRwithAndrew  Год назад +1

      There's some code in the Event System that prevents events if the cursor is locked if I remember correctly. There isn't an easy workaround, but you may be able to copy the script into a new file and make the necessary edits.

  • @castlecodersltd
    @castlecodersltd 3 месяца назад

    Very helpful, thank you 🙂

  • @indikaWijesooriya
    @indikaWijesooriya 2 года назад +2

    This is a great tip Andrew!. Thanks. It's been a while :-)
    I'd also like to know your take on custom graphic raycasters. Eg: Projecting a UI to a curved object (probably with render texture) and getting the raycast input to convert to a UI input. Mainly in VR

    • @VRwithAndrew
      @VRwithAndrew  2 года назад

      I haven't really created my own raycaster before. But, I'm pretty sure you can! I also have some experience with the Curved UI Asset. Technically, you may be able to use the existing Ray Interactor from XRI, a Custom Event System, and a visual element to bend the UI.

  • @ritori3556
    @ritori3556 Год назад +2

    Hi! Thank you for great tip! However, as a beginner, I suffered a lot in implementing it. Could you please share or show in your tutorial MaterialApplier script :( In trying to make it on my own, I got completely lost

    • @VRwithAndrew
      @VRwithAndrew  Год назад

      It's just a simple example script and not necessary for the implementation. You can easily just put debug statements instead.

  • @ДосталиЕвский
    @ДосталиЕвский Год назад

    Can you please clarify how to select an object using a gamepad controller? I'm currently in the process of setting up my input systems for the gamepad, but I'm unsure of how to accomplish this task. Thank you for your assistance!

  • @mast1665
    @mast1665 Год назад +1

    Are there any more resources on this?
    I just started my unity journey and cant quite get my head around this system.
    The Events seem to fire endlessly, not only when (for example) clicking on the GameObject I added this script too...
    No matter where I move/click the mouse. The script answers always.

    • @VRwithAndrew
      @VRwithAndrew  Год назад

      Not exactly! However, feel free to join the Discord, and we'll see if we can figure it out.

    • @mast1665
      @mast1665 Год назад +1

      @@VRwithAndrew I had to use a box collider! Today was a learn intensive day. Thank you :)

  • @marcoballan4067
    @marcoballan4067 3 месяца назад

    is there any way of implementig this with right clicks or does it only works with left clicks?

    • @VRwithAndrew
      @VRwithAndrew  3 месяца назад

      Yeah, you can use the PointerEventData with some code like this.
      public override void OnPointerClick(PointerEventData eventData)
      {
      if (eventData.button == PointerEventData.InputButton.Right)
      {
      // Your code
      }
      }

  • @tahirdevlog2047
    @tahirdevlog2047 11 месяцев назад

    thank you

  • @Arsen592_Old
    @Arsen592_Old Год назад

    Strange but I don't have Input System UI Input Module in my EventSystem, and I can't add it

    • @VRwithAndrew
      @VRwithAndrew  Год назад

      Do you have the Input System Package installed?

    • @Arsen592_Old
      @Arsen592_Old Год назад

      @@VRwithAndrew oh I didn't input it, thanks

  • @AgalyAbdyev
    @AgalyAbdyev Год назад +1

    sorry but i have error on MaterialApplier. How to solve ?

    • @VRwithAndrew
      @VRwithAndrew  Год назад +1

      That's just an example script. You can have a print statement there instead.

    • @DexterCrappell
      @DexterCrappell 10 месяцев назад +1

      @@VRwithAndrew I just started with unity, how would I add the print statement?

    • @VRwithAndrew
      @VRwithAndrew  10 месяцев назад +1

      @@DexterCrappell Within the click functions, you can write...
      print("Click");
      or
      print("Hover");
      Depending upon what the pointer event is

  • @ClimFreeFeelRain
    @ClimFreeFeelRain Год назад +1

    How can I

  • @appleseedgames6934
    @appleseedgames6934 Год назад +3

    Thought this would really easy but magically it's not working, followed the tutorial the exact same and followed other issued people have had but it's just simply not returning a debug on click at all

    • @appleseedgames6934
      @appleseedgames6934 Год назад +1

      Solution: Cursor.lockState isn't compatible with it. Pretty making this entirely useful except for a handful of cases, don't waste your time with this

  • @Dan-ed1sk
    @Dan-ed1sk 3 дня назад

    This is not really helpful, you don't provide enough info

  • @ashwinsuresh1476
    @ashwinsuresh1476 2 года назад +3

    andrew tate , top g